Book a Demo

Author Topic: Guid references to deleted model elements etc  (Read 6245 times)

trickster60

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Guid references to deleted model elements etc
« on: September 17, 2012, 02:55:41 pm »
Hi,

I have been developing an addin and in some of my bespoke stereotypes I have a need to create taggedvalues in which I store the guid reference of some element in an EA Model. If I delete the referenced element from the EA model will EA automatically trawl through the EA model looking for and deleting any guid referring to the deleted element, or will I have to write code to do that?

Regards, Nick.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #1 on: September 17, 2012, 03:45:25 pm »
Are you using "RefGUID" custom tagged value types? It appears that if you use one of those then the value is cleared if you delete the element that it references. (I just tried it)

[edit]This is how EA has worked since at least build 801. However, it probably shouldn't work that way. If you are referencing an element in a controlled package and you delete the element, the deleted element can be restored. When that happens, you would want all the referencing tagged values to still be referencing the element. We should probably fix this.[/edit]
« Last Edit: September 17, 2012, 04:49:22 pm by KP »
The Sparx Team
[email protected]

trickster60

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #2 on: September 17, 2012, 05:12:22 pm »
Quote
Are you using "RefGUID" custom tagged value types? It appears that if you use one of those then the value is cleared if you delete the element that it references. (I just tried it)

[edit]This is how EA has worked since at least build 801. However, it probably shouldn't work that way. If you are referencing an element in a controlled package and you delete the element, the deleted element can be restored. When that happens, you would want all the referencing tagged values to still be referencing the element. We should probably fix this.[/edit]

I haven't used the refGUID predefined tagged value type. I was simply creating (in code) a tagged value (via AddNew() ) and setting the Value to the guid of the element I wanted to reference.

How would I add to TaggedValues a new TaggedValue of type refGUID (via code)?

I didn't know you could restore an element that had been deleted from the model.

Thanks

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #3 on: September 18, 2012, 09:24:11 am »
Quote
How would I add to TaggedValues a new TaggedValue of type refGUID (via code)?
The easiest way would be to define a stereotype that applies the tagged value (this will have to be done in a profile). Then via code you just create a stereotyped element and it will be created with the tagged value.

Quote
I didn't know you could restore an element that had been deleted from the model.
Export a package to XMI, delete the package, re-import the XMI :)
« Last Edit: September 18, 2012, 09:25:17 am by KP »
The Sparx Team
[email protected]

trickster60

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #4 on: September 18, 2012, 04:14:09 pm »
Quote
Quote
How would I add to TaggedValues a new TaggedValue of type refGUID (via code)?
The easiest way would be to define a stereotype that applies the tagged value (this will have to be done in a profile). Then via code you just create a stereotyped element and it will be created with the tagged value.

Quote
I didn't know you could restore an element that had been deleted from the model.
Export a package to XMI, delete the package, re-import the XMI :)

Well I have runs some experiments and discovered that when I set the value of a regular string type TaggedValue to the GUID of an element and then I delete the element lo and behold the value of the taggedvalue automatically becomes "".

I conclude then that when an element is deleted from the model EA does simple trawl through the model looking for any TaggedValue with the element's GUID and wipes them. Brilliant! Nice (undocumented) feature  ;)

bsd103

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #5 on: October 06, 2012, 05:29:56 am »
Is there a way to define a tagged value with a tagged value type without defining the TV in a stereotype via UML profile?  I have elements already using a UML profile with defined tagged values, but there are special cases where I want one or two to have a tagged value specific to that element.

Quote
Quote
How would I add to TaggedValues a new TaggedValue of type refGUID (via code)?
The easiest way would be to define a stereotype that applies the tagged value (this will have to be done in a profile). Then via code you just create a stereotyped element and it will be created with the tagged value.

Quote
I didn't know you could restore an element that had been deleted from the model.
Export a package to XMI, delete the package, re-import the XMI :)

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #6 on: October 08, 2012, 01:16:58 pm »
Quote
Is there a way to define a tagged value with a tagged value type without defining the TV in a stereotype via UML profile?  

Sure. Go Settings > UML Types > Tagged Value Types to define your tagged value types, then select an element and Ctrl+Shift+T and choose your tagged value type from the list.
The Sparx Team
[email protected]

bsd103

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Guid references to deleted model elements etc
« Reply #7 on: October 08, 2012, 11:45:24 pm »
Sorry, I should have been more specific.  I am trying to do this in C# as part of an add-in.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Guid references to deleted model elements etc
« Reply #8 on: October 09, 2012, 12:54:06 am »
Once you define the tagged value type you can just use its name when adding a new tagged value.

Geert