Author Topic: Document Template Filter Connector Target Elements  (Read 2064 times)

JonathanP

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Document Template Filter Connector Target Elements
« on: August 12, 2014, 06:24:02 am »
Is there a way to filter elements by type or preferably stereotype when generating a document from a template with Package->Element->Connector->Target->Element?

Example: I am generating a use case report from a package that contains my use case elements. The use cases have dependency connectors to requirement elements and screen elements. Some of the requirements have a stereotype of "Assumption." In my template I have a table for the use case element properties including an "Assumptions" field that I would like to populate with Connector->Target->Element properties, but restrict it to only elements with the "Assumption" stereotype. Is this possible?

I have tried using the Document Options->Exclude Filters and Element Filters, but they appear to only filter the elements in the package and not the element connected. The closest I could get was using the Exclude Filter for connector type to get it to only show dependencies, but that still includes anything that is connected through dependency and not specifically an element type or stereotype.

-JP

JonathanP

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Document Template Filter Connector Target Elem
« Reply #1 on: August 13, 2014, 05:21:13 am »
Just in case anyone is wondering how this is done, I received a response from support and it must be done using a template fragment and a custom SQL query. Here is the query I use to get related target elements that are of the stereotype "Assumption":

SELECT t_connector.Start_Object_ID, t_connector.End_Object_ID, t_object.Object_ID, t_object.Object_Type, t_object.Name, t_object.Stereotype
FROM t_connector
INNER JOIN t_object
ON t_connector.End_Object_ID=t_object.Object_ID
WHERE t_connector.Start_Object_ID = #OBJECTID#
AND t_object.Stereotype = 'Assumption'

#OBJECTID# will pass in the Object_ID of the element that is being generated by the main template when generating the report.

-JP

juliek01

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Document Template Filter Connector Target Elem
« Reply #2 on: May 14, 2015, 04:57:56 pm »
I want to do something similar i.e. filter by status on the connector elements.

What would the SQL be in this instance?

Also, where do I record this in Document Options? When I go to the Custom Query tab I get the message "Custom Queries are only available in custom fragments".

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1214
  • Karma: +12/-3
  • Read The Help!
    • View Profile
Re: Document Template Filter Connector Target Elem
« Reply #3 on: May 19, 2015, 09:04:58 am »
I'm not sure about the SQL, but presumably you would use something like t_object.Status instead of t_object.Stereotype.

You are probably getting the error message because you are working on a system-supplied Template Fragment (or even a full template). You need to create your own, custom, template fragment.
Best Regards, Roy

juliek01

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Document Template Filter Connector Target Elem
« Reply #4 on: May 19, 2015, 12:38:18 pm »
Thanks Roy.

I have eventually got this to work with a template fragment using a custom SQL query.

Here is my SQL for other's benefit.

SELECT t_object.Name as objectname, t_object.status as objectstatus, t_object.stereotype as objectstereotype,
t_object.Alias as objectalias, t_object.Note as objectnotes, t_object.object_type as objecttype,
t_object.Pdata2 as objectpriority,
tagsystem = (select tv.value from t_objectproperties tv
where tv.Object_ID = t_object.Object_ID and tv.property = 'System'),
taglatency = (select tv.value from t_objectproperties tv
where tv.Object_ID = t_object.Object_ID and tv.property = 'Response Time'),
tagmobility = (select tv.value from t_objectproperties tv
where tv.Object_ID = t_object.Object_ID and tv.property = 'Mobility'),
tagreplatency = (select tv.value from t_objectproperties tv
where tv.Object_ID = t_object.Object_ID and tv.property = 'Report Latency')
FROM t_connector
INNER JOIN t_object
ON t_connector.start_Object_ID=t_object.Object_ID
WHERE t_connector.end_Object_ID = #OBJECTID#
and t_object.status = 'Proposed'
and t_object.object_type = 'Requirement'

It was good to work out where all the values are stored in t_object and how to link to my tagged values.

My remaining problem is that the content of the notes field is being displayed with html tags, which is not suitable for my end users. Do you know of a way I can address this issue?

I can see this has been reported via another post and there was mention that this is a restriction of using SQL and that I should use a custom script. But how would this work? Can I have a custom SQL and a custom script working together? What would the script look like? Or do I replace my SQL with a script? Everything works except how the notes text is displayed.
« Last Edit: May 19, 2015, 04:11:32 pm by juliek01 »