Author Topic: Script creation of Model Glossary Entry broken  (Read 1910 times)

workingmatt

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Script creation of Model Glossary Entry broken
« 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)
« Last Edit: July 30, 2023, 06:16:49 am by workingmatt »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Script creation of Model Glossary Entry broken
« Reply #1 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13305
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script creation of Model Glossary Entry broken
« Reply #2 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