Book a Demo

Author Topic: Finding operations in all diagrams / traceability  (Read 17092 times)

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Finding operations in all diagrams / traceability
« on: May 27, 2010, 11:29:29 pm »
Does anybody know if it's possible to find in wich (sequence) diagrams a specific operation is used?

I know that it's possible to find a class in all diagrams, but is this also possible for operations?

Kind regards.

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 operations in all diagrams / traceabil
« Reply #1 on: May 28, 2010, 03:32:04 pm »
Not natively, but you can write either a search, or an addin to do so.
As SQL search you could do something like this:
Code: [Select]
select distinct d.ea_guid as CLASSGUID,d.Diagram_Type as CLASSTYPE,d.name as Name
,package.name as 'Package Name',package_p1.name as 'Package level -1',package_p2.name as 'Package level -2',package_p3.name as 'Package level -3'
from (((((t_connector c
join t_diagram d on c.diagramID = d.diagram_id)
join t_package as package on d.package_id = package.package_id)
left join t_package as package_p1 on package_p1.package_id = package.parent_id)
left join t_package as package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package as package_p3 on package_p3.package_id = package_p2.parent_id)
where
c.name like '%<Search Term>%' + '(%)'

Even better is to write an addin that shows the diagrams your operation is used in, because you can then work based on the operation guid rather then the name.
I'll try to post some of the code I used for my addin in a next reply.

Geert

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 operations in all diagrams / traceabil
« Reply #2 on: May 28, 2010, 04:01:22 pm »
For Addin I use following code:
Code: [Select]
       /// <summary>
        /// returns all messages that call this operation
        /// </summary>
        /// <returns>all messages that call this operation</returns>
        public List<UMLMessage> getCallingMessages()
        {
            //this one we will try to find with a cunning sql query directly
            //sometimes the guid of an operation is not the same as the guid mentioned in the tag
            //to be sure the try to get both.
            string sqlQuery =
                "select c.Connector_ID  from ((t_connector c "
                + " inner join t_connectortag ct on ct.ElementID = c.Connector_ID) "
                + " inner join t_operation o on ct.VALUE = o.ea_guid) "
                + " where c.Connector_Type = 'Sequence' "
                + " and ct.Property = 'operation_guid' "
                + " and ct.VALUE = '" + this.wrappedOperation.MethodGUID + "'"
                + " Union "
                + " select c.Connector_ID  from ((t_connector c "
                + " inner join t_connectortag ct on ct.ElementID = c.Connector_ID) "
                + " inner join t_operationTag ot on ct.VALUE = ot.VALUE) "
                + " where c.Connector_Type = 'Sequence' "
                + " and ct.Property = 'operation_guid' "
                + " and ot.ElementID = " + this.wrappedOperation.MethodID;
            return this.model.getRelationsFromQuery(sqlQuery).Cast<UMLMessage>().ToList();
        }
The opration getRelationsFromQuery looks like this:
Code: [Select]
       /// <summary>
        /// returns the relations found by the given query
        /// </summary>
        /// <param name="sqlQuery">the query to use</param>
        /// <returns>the relations returned by the query</returns>
        public List<UMLRelation> getRelationsFromQuery(string sqlQuery)
        {
            //get the nodes with the name "Connector_ID"
            XmlDocument xmlrelationIDs = this.SQLQuery(sqlQuery);
            XmlNodeList relationIDNodes = xmlrelationIDs.SelectNodes("//Connector_ID");
            List<UMLRelation> relations = new List<UMLRelation>();
            foreach (XmlNode relationIDNode in relationIDNodes)
            {
                string relationID = relationIDNode.InnerText;
                UMLRelation relation = this.getRelationByID(relationID) as UMLRelation;
                relations.Add(relation);
            }
            return relations;
        }
and getRelationByID is as follows:
Code: [Select]
       /// <summary>
        /// returns the relation with the given id
        /// </summary>
        /// <param name="ID">the id of the relation</param>
        /// <returns>the relation with the given id</returns>
        public UMLRelation getRelationByID(string ID)
        {
            UMLRelation returnedRelation = null;
            int relationID;
            if (int.TryParse(ID, out relationID))
            {
                returnedRelation = (UMLRelation)EAWrapperFactory.createEAWrapper(this, this.wrappedModel.GetConnectorByID(relationID));
            }
            return returnedRelation;
        }

the wrappedModel is my actual EA Repository object, and createEAWrapper create a wrapper for the EA.Connector object.

From those messages I then get the diagrams:
Code: [Select]
       /// <summary>
        /// returns the diagram on which this message is defined
        /// </summary>
        /// <returns>the diagram on which this message is defined</returns>
        public UMLDiagram getDiagram()
        {
            return this.model.getDiagramByID(this.wrappedConnector.DiagramID.ToString());
        }
the getDiagramByID looks like:
Code: [Select]
       /// <summary>
        /// returns the diagram with the given id
        /// </summary>
        /// <param name="ID">the id of the diagram</param>
        /// <returns>the diagram with the given id</returns>
        public UMLDiagram getDiagramByID(string ID)
        {
            UMLDiagram returnedDiagram = null;
            int DiagramID;
            if (int.TryParse(ID, out DiagramID))
            {
                returnedDiagram = (UMLDiagram)EAWrapperFactory.createEAWrapper(this, this.wrappedModel.GetDiagramByID(DiagramID));
            }
            return returnedDiagram;
        }
Then if I find only one diagram then I open it directly. If there are more diagrams then I show them in a little popup window and allow the user to open one or more of those.
The code to open the diagram is as follows:
Code: [Select]
       public void OpenDiagram(EADiagram diagram)
        {
            int diagramID;
            if (int.TryParse(diagram.getID(),out diagramID))
            {
                this.wrappedModel.OpenDiagram(diagramID);
            }
        }
That's about it, I have now almost reached the maximum of 5000 characters for one post.

Geert
« Last Edit: May 28, 2010, 04:01:54 pm by Geert.Bellekens »

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #3 on: May 28, 2010, 06:32:43 pm »
Thanks Geert!

Can you tell me how I can use your code? How does it work? And you do I create the addin-in and use it?

I'm a newbe! :)

Thanks so much!

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 operations in all diagrams / traceabil
« Reply #4 on: May 28, 2010, 07:07:29 pm »
Eh, not in five minutes.
The best place to start is http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/introduction_2.htm
That should help you (there are example addins available for download as well) to get started.
Once you have a basic addin running I suggest you look at my code and see what you can use of it.

Geert

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #5 on: May 28, 2010, 07:59:09 pm »
Hi Geert

Great reply, but just a thought, EA Access SQL search does not appear to support LIKE '%' wildcard searches, however a change to

ALIKE ' %<Search Term>%' + '(%)'

works just fine!

Cheers

Phil
« Last Edit: May 28, 2010, 07:59:30 pm by philchudley »
Models are great!
Correct models are even greater!

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 operations in all diagrams / traceabil
« Reply #6 on: May 28, 2010, 08:01:00 pm »
Yes, you are right.
In case of Access you can also use "*" as wildcard character.
(I didn't know about the ALIKE operator)
Sadly MS-Access is still not ANSI SQL compliant.

Geert

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #7 on: May 28, 2010, 08:11:13 pm »
Thanks again. This is going to be difficult... I'm a functional designer not a programmer... So my programming skills are... well... poor.

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 operations in all diagrams / traceabil
« Reply #8 on: May 28, 2010, 09:13:32 pm »
Miko,

Don't worry. Once you get started, it's not all that difficult.
If you have any questions, or you run into specific problems, just let us know on the forum.
We'll try to support you as good as we can  :)

Geert

PS. I'm more of a functional analyst myself (programming is more of a hobby for me), so I know where you are coming from.

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #9 on: May 28, 2010, 09:17:15 pm »
Hi Geert,

Thanks for the offer.

What kind of development tool do you use? Microsoft Visual Basic? Where can I get it? Or a tool like it?

Regards,
Miko

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 operations in all diagrams / traceabil
« Reply #10 on: May 28, 2010, 09:33:29 pm »
Miko,

At work I use Visual Studio 2008, but at home I develop my addins with Visual C# 2010 Express (the free edition)

Geert

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #11 on: May 28, 2010, 09:35:08 pm »
Rats... just started to download visual basic express 2010. Is C# better?

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 operations in all diagrams / traceabil
« Reply #12 on: May 28, 2010, 09:41:06 pm »
It would help if you wanted to use the code snippets I posted.
For the rest its just a matter of syntax. Most people like C# syntax more then VB syntax (including myself).

Geert

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #13 on: May 28, 2010, 09:42:37 pm »
Ok. I'll download Visual C# 2010 Express

mikob

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Finding operations in all diagrams / traceabil
« Reply #14 on: May 28, 2010, 11:07:57 pm »
I'm looking at the following steps, but it isn't getting any clearer...
Create an Add-In
An Enterprise Architect Add-In can be created in four steps:

1.Use a development tool to create an ActiveX COM DLL project. Visual Basic users, for example, choose File-Create New Project-ActiveX DLL.
2.Connect to the interface using the syntax appropriate to the language as detailed in the Connecting to the Interface topic.
3.Create a COM Class and implement each of the general Add-In Events applicable to your Add-In. You only have to define methods for events to respond to.
4.Add a registry key that identifies your Add-In to Enterprise Architect, as described in the Deploying Add-Ins topic.

How do I create an ActiveX COM DLL project??