Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: workingmatt on July 30, 2023, 04:48:08 am

Title: Script creation of Model Glossary Entry broken
Post by: workingmatt on July 30, 2023, 04:48:08 am
I used a script to create a GlossaryCategory package and put a GlossaryEntry element in it. The new GlossaryEntry is not recognised as a glossary term after clicking Reload Glossary from its context menu. My script is below.

When I use Add Element... to create a GlossaryElement in my new GlossaryCategory package it is recognised as a glossary term after clicking Reload Glossary.

I've checked many properties of the not working, script created GlossaryEntry against the properties of the Add Element created one and cannot spot any difference. Tried in v15.2 and v16.1.

Has anyone been able to create a Model Glossary Entry (not a Repository.Term) using a script?

Creation code:
Code: [Select]
Set newPackage = mdalPackage.Packages.AddNew("NewCategory", "")
newPackage.Update
newPackage.StereotypeEx = "Glossary::GlossaryCategory"
newPackage.Update

Set newElement = newPackage.Elements.AddNew("AardvarkA", "Entity")
newElement.Update
newElement.Stereotype = "Glossary::GlossaryEntry"
newElement.Update

Properties test code
Code: [Select]
Session.Output("Name:"&elem.Name & " Stereotype:"&elem.Stereotype&" StereotypeEx:"&elem.StereotypeEx&_
" FQStereotype:"&elem.FQStereotype&" ObjectType:"&elem.ObjectType&" Type:"&elem.Type&" FQName:"&elem.FQName&" Subtype:"&elem.Subtype)
Title: Re: Script creation of Model Glossary Entry broken
Post by: qwerty on August 01, 2023, 12:44:25 am
Your issue is that you need to create a Class, not an Entity.

Code: [Select]
Set newElement = newPackage.Elements.AddNew("AardvarkA", "Class")
q.
Title: Re: Script creation of Model Glossary Entry broken
Post by: Geert Bellekens on August 22, 2023, 05:46:01 pm
Even better is to create the element from the FQStereotype directly:

Code: [Select]
Set newElement = newPackage.Elements.AddNew("AardvarkA", "Glossary::GlossaryEntry")
newElement.Update

No more need to update the stereotype(Ex)

The only time this might not work is if the stereotype is used on multiple base types (such as BPMN intermediate events)
In that case you might end up with the wrong basetype.

Geert