Book a Demo

Author Topic: [SQL Fragment] Generate Documentation by selecting OperationID  (Read 9113 times)

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
[SQL Fragment] Generate Documentation by selecting OperationID
« on: December 19, 2019, 04:21:57 am »
Hello,

I try to extract some value with a Fragment with a SQL query, but I don't have acces to the Id of the operation I currently processing.
I would like to use #OPERATIONID# like #OBJECTID# but it seems not available :

Here my query tested in "Find in Project" and it works :
SELECT allfunction.* FROM t_operation AS allfunction
INNER JOIN t_operationtag AS function_tag ON allfunction.OperationID = function_tag.ElementID, t_operation AS myFunction
WHERE myFunction.Object_ID = '773'
AND myFunction.OperationID = '2758'
AND function_tag.Property = 'Calls'
AND function_tag.VALUE LIKE CONCAT("%", myFunction.Name, "%")

And here in my SQL Fragment :
SELECT allfunction.Name AS Name FROM t_operation AS allfunction
INNER JOIN t_operationtag AS function_tag ON allfunction.OperationID = function_tag.ElementID, t_operation AS myFunction
WHERE myFunction.Object_ID = '#OBJECTID#'
AND myFunction.OperationID = '#OPERATIONID#'
AND function_tag.Property = 'Calls'
AND function_tag.VALUE LIKE CONCAT("%", myFunction.Name, "%")

This query return all the operation who calls the operation myFunction.OperationID = '#OPERATIONID#'
I can't find a solution to get the OperationID.

Hope someone can help me to figure this out ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #1 on: December 19, 2019, 04:50:12 am »
I don't think there's a macro #OPERATIONID#. Did you find that in the documentation, or did you just invent it yourself?

Geert

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #2 on: December 19, 2019, 07:29:24 pm »
I just invent it myself, I saw in other Topic you said that didn't exist :
https://www.sparxsystems.com/forums/smf/index.php/topic,40941.msg248931.html#msg248931

But I try to find a way to identify the name of the operation I currently processing.
This SQL fragment is call by a Template in a section "method> <method"
In a template I could retrieve the name by using {Meth.Name} but I dont know how to do it in the SQL query.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #3 on: December 19, 2019, 07:37:51 pm »
I don't think you can call fragments in an method> section.
What I do in these cases, is to create a fragment on the element> level that reports all of my operations (often using an SQL fragment with the output in a table)

Geert

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #4 on: December 19, 2019, 09:14:29 pm »
Thank for your support, I think it works to call SQL fragment in the section method>
I will try to change all the template to remove the sections attribute> and method> sections.
Is it possible to call a SQL fragment into another SQL fragment? (I tried but it seems not working)
Or I have to extract all the attribute/method of my class in only one SQL Fragment, because for the moment I use the sections to call multiple SQL fragment to extract information, bellow the actual template I using :
package >
1.1 Package  {Pkg.Name}
element >
1.1.1 Class {Element.Name}
{Element.Notes}
{Template - SDD Class Diagram}

1.1.1.1 Attributes
attribute >
{Template - SDD attributes full}
< attribute

1.1.1.2 Methods
method >
{Template - SDD CallsBy} <= Here is the current SQL fragment with my problem
{Template - SDD methods full} <= I would like to call in this SQL fragment (but not working)
< method

1.1.1.3 Interaction Diagram

child elements >
{Template - Interaction diagram}
< child elements
< element
child packages >
< child packages
< package

-------------------------------------------------
And here the SQL Fragment {Template - SDD methods full} :
package >
element >
method >
service: {Meth.Name} (
parameter >      {MethParameter.Name} : {MethParameter.Type} ({MethParameter.Kind})  **{MethParameter.Notes}**
< parameter ) return {Meth.Type}

Overview:
{Meth.Behavior}

Satisfies:
{Meth.valueOf(Satisfies)}

Rationale:
{Meth.valueOf(Rationale)}

Description :
{Meth.Notes}

Called by:
{Meth.valueOf(Called_By)} <= Here I would call {Template - SDD CallsBy}

Subordinates:
{Meth.valueOf(Calls)}

Dependencies:
{Meth.valueOf(Constraints)}

Resources:
{Meth.valueOf(Uses_Extern)}
{Meth.valueOf(Use_Extern)}


Data:
{Meth.valueOf(Uses_Local)}
{Meth.valueOf(Use_Local)}

Error code:
{Meth.valueOf(Error_Code)}

< method
child elements >
< child elements
< element
< package


Edit : add where I would call {Template - SDD CallsBy} if Fragment could call another Fragment.
« Last Edit: December 19, 2019, 09:20:57 pm by YanDJ »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #5 on: December 19, 2019, 09:57:07 pm »
I think I've seen something in the release notes of v15 indicating that you can use nested fragments, but I'm not sure if that will be helpful to you as you can't pass the operationID to your sub-fragment.

So I guess you'll have to combine both fragments into a single fragment

Geert

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #6 on: January 22, 2020, 09:13:03 pm »
Hello, So it takes me some time to write the query to retrieve all my info.
I share with you if it can help someone :
SELECT op.OperationID, op.Name AS opName,
      optag1.value AS satisfies,
      optag2.value AS rationale,
      optag3.value AS subordinates,
      optag4.value AS dependencies,
      optag5.value AS resources,
      optag6.value AS datas,
      optag7.value AS errorCode,
      GROUP_CONCAT( DISTINCT CONCAT_WS(' *** ',CONCAT_WS(' | ',CONCAT_WS(' : ',opParams.Name,opParams.Type),opParams.Kind),opParams.Notes) ORDER BY opParams.Name SEPARATOR '\n') AS AllParams,
      op.Type AS opRetType,
      op.Behaviour AS opBehaviour,
      op.Notes AS opNotes,
      tCallsBy.CallsBy AS CallsBy
FROM t_object AS obj
    LEFT JOIN  t_operation AS op ON  obj.Object_ID = op.Object_ID
   LEFT JOIN 
        (SELECT t2.OperationID, t2.name, group_concat(t1.name) AS CallsBy
      FROM  t_operation t1
         LEFT JOIN 
            (SELECT to2.OperationID, to3.ElementID, to2.name
            FROM  t_object to1
               LEFT JOIN  t_operation to2
                  ON  to1.Object_ID = to2.Object_ID
               LEFT JOIN  t_operationtag to3
                  ON  to3.VALUE LIKE CONCAT("%", to2.Name, "%")
            WHERE  to3.Property = 'Calls'
            AND to1.Object_ID = '#OBJECTID#') t2
         ON  t1.OperationID = t2.ElementID
      WHERE  t2.ElementID is not null
      GROUP BY t2.name) tCallsBy ON  op.OperationID = tCallsBy.OperationID
   LEFT JOIN  t_operationparams ASopParams ON  op.OperationID = opParams.OperationID
   LEFT JOIN  t_operationtag AS optag1 ON  (op.OperationID = optag1.ElementID AND  optag1.Property = 'Satisfies')
   LEFT JOIN  t_operationtag AS optag2 ON  (op.OperationID = optag2.ElementID AND  optag2.Property = 'Rationale')
   LEFT JOIN  t_operationtag AS optag3 ON  (op.OperationID = optag3.ElementID AND  optag3.Property = 'Calls')
   LEFT JOIN  t_operationtag AS optag4 ON  (op.OperationID = optag4.ElementID AND  optag4.Property = 'Constraints')
   LEFT JOIN  t_operationtag AS optag5 ON  (op.OperationID = optag5.ElementID AND  optag5.Property = 'Use_Extern')
   LEFT JOIN  t_operationtag AS optag6 ON  (op.OperationID = optag6.ElementID AND  optag6.Property = 'Use_Local')
   LEFT JOIN  t_operationtag AS optag7 ON  (op.OperationID = optag7.ElementID AND  optag7.Property = 'Error_Code')
WHERE  obj.Object_ID = '#OBJECTID#'
GROUP BY op.Name


But I have a problem the text return by op.Behaviour AS opBehaviour and op.Notes AS opNotes have the formating inside (i>, /i>, b>, ...), do you know If it is possible to format correctly the text when it is print in the generated doc ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #7 on: January 22, 2020, 09:34:52 pm »
But I have a problem the text return by op.Behaviour AS opBehaviour and op.Notes AS opNotes have the formating inside (i>, /i>, b>, ...), do you know If it is possible to format correctly the text when it is print in the generated doc ?

Yes, you have to tell EA that this field contains formatted text.
The way to differs a bit between SQL server or .eap.

For SQL Server you have to add the suffix "-formatted" to your field name
op.Behaviour AS [opBehaviour-formatted]
In you template you then use this field like this
{opBehaviour.formatted}

(yes a "." instead of "-")

Geert

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #8 on: January 22, 2020, 10:10:43 pm »

For SQL Server you have to add the suffix "-formatted" to your field name
op.Behaviour AS [opBehaviour-formatted]
In you template you then use this field like this
{opBehaviour.formatted}

I try but it didn't works. Now in the doc, I didn't have anymore text but only : opBehaviour.formatted
I try with {opBehaviour-formatted}, I get the text but I still have <i>,<b>...

Maybe I have to activate an option ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #9 on: January 22, 2020, 10:50:27 pm »
Check the documentation on SQL Fragments. It is documented there how to do it.

This works for me on an SQL Server repository.

Geert

YanDJ

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #10 on: January 23, 2020, 12:24:07 am »
I found int the documentation for EA v14, I have to write :
op.Behaviour AS "opBehaviour.Formatted"
instead of :
op.Behaviour AS [opBehaviour-formatted]

And it works for me :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: [SQL Fragment] Generate Documentation by selecting OperationID
« Reply #11 on: January 23, 2020, 12:26:36 am »
I found int the documentation for EA v14, I have to write :
op.Behaviour AS "opBehaviour.Formatted"
instead of :
op.Behaviour AS [opBehaviour-formatted]

And it works for me :)

That doesn't depend on the version, but on the database.
For a .eap file that might work, but it won't if you try the same on an SQL Server repository.

Geert