Author Topic: How to add/remove Context References in use cases  (Read 4294 times)

Piotr123

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
How to add/remove Context References in use cases
« on: August 08, 2012, 06:33:30 pm »
Hi,
How can I add/remove Context References elements in use case (tab Context References in scenarios)
I can add that context reference manually (pop up menu: "Insert Context Reference" in "Uses" field) but I can't find any API (VBScript) to add/remove such references.

Piotr

Exart

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to add/remove Context References in use ca
« Reply #1 on: August 09, 2012, 01:06:34 am »
Currently the only way to do this is manually deleting the relationship in UseCase properties in section Links.
But I would be grateful if someone could indicate how to do it automatically.

Piotr123

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to add/remove Context References in use ca
« Reply #2 on: August 09, 2012, 05:34:46 am »
I must do it automatically. I have some hundreds of use case do process. I can't spend months on it >:(

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add/remove Context References in use ca
« Reply #3 on: August 09, 2012, 03:41:41 pm »
Piotr,

I don't think that this is really exposed in the API, so you'll probably have to do it the hard way.

I think the context references are stored in xml format in EA.Scenario.XMLContent (t_objectscenarios.XMLContent)
An example from my model:
Code: [Select]
<path>  
<context>    
<item oldname="B_FADEOList_Window" guid="{E601C4F5-0B08-4e2a-A2E3-638BC9CD4270}"/>    
<item oldname="FADEOCommunication" guid="{F3E6155A-DFD7-43c9-BC5C-E5D723F243D8}"/>  
</context>  
</path>
(indentation added for clarity)
Just be careful with that field, it contains more then the context references alone, it also stores the scenariosteps, the weather forecast, and the stockprices for Apple and Google ::)

I'm also not sure if you delete the reference it won't come back. I've noticed that the context references in my use case have been added automatically based on the actual relations (most of them traceability dependencies) of my use case.
So I guess if you remove a context reference, you might also need to remove the actual relation between the use case and the related element.

Geert

Piotr123

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to add/remove Context References in use ca
« Reply #4 on: August 09, 2012, 04:55:11 pm »
Thanks Geert for that idea.
I'll try to do that this way.

Piotr

workingmatt

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: How to add/remove Context References in use cases
« Reply #5 on: October 03, 2019, 01:23:58 am »
I would really like to know if this worked, although I'm only trying to discover these context references (to then place the relevant diagramObjects on a diagram). So I did a 'Select * from t_objectscenarios' in the SQL Scratch Pad (I do know how to do this in scripts too). The t_objectscenarios table contains rows including Object_ID pointing to a UseCase, Scenario [name], ScenarioType and XMLContent that has more than Geert posted above...
<path>
<step name=... guid=... level="step number"... uses="names of things I'm looking for" uselist="" result=... state=... trigger=... link=... \>
<step> more of these
<context>
<item oldname="one name I'm looking for" guid=...\>
<item> more of these
</context>
</path>

The uses field in <step> is element.name text separated by a space.
The oldname field in <item> is element.name text followed by guid field.
I think that's enough for what I want to do. I'm not sure what happens if there are entries with identical names in the uses part of a Use Case Scenario step, needs more investigation...

The context probably contains any elements that are highlighted in the Action section of the Use Case Scenarios dialog, but I have no idea how they are stored. Any comments gratefully received!
« Last Edit: October 03, 2019, 01:51:15 am by workingmatt »