Author Topic: "Clean" way to get MDG technology info  (Read 1198 times)

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
"Clean" way to get MDG technology info
« on: June 12, 2019, 01:28:52 am »
Hi,

I'm trying to create a connector using an MDG Technology stereotype (Archimate in my case).
The stereotype defined in the MDG technology "maps" to a base connector type in the MDG tech XML file.

Example:
<Stereotype notes="" name="ArchiMate_UsedBy" hideicon="0" borderwidth="-1" bordercolor="-1" fontcolor="-1" bgcolor="-1" metatype="UsedBy">
  [...]
  -<AppliesTo>
    -<Apply type="Dependency">
      [...]
    </Apply>
  </AppliesTo>
</Stereotype>

So (if I'm getting this right) when creating a connector with the "Archimate_UsedBy" stereotype EA will create a "Dependency" type connector.
I want to be able to set the right "base type" (Dependency) when creating a new connector based on the "stereotype" (Archimate_UsedBy).

Problem is, this mapping does seem to exist only in the MDG XML file, so it cannot be accessed (or at least I haven't figured out how) from the automation interface... Unless I parse the XML myself, which seems to be troublesome (would need first to figure out where the XML is, then parse it manually :-\)

Before I jump into this I was wondering if there's a cleaner way to achieve getting access to the MDG technology info from the automation interface?

Thanks

Phil

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9469
  • Karma: +266/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: "Clean" way to get MDG technology info
« Reply #1 on: June 12, 2019, 02:56:54 am »
No, there is no better way.
Either you parse the XML, or you hardcode all the info you need.

Or, and this is a long shot, you might be able to use the fully qualified stereotype in the AddNew() operations as the type parameter.
So something like
Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Archimate2::ArchiMate_UsedBy");(double check to make sure the syntax and names are correct)
Then you can check the type of the just created connector.

Not sure if this works, but it's worth a try.

Geert

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #2 on: June 12, 2019, 04:53:22 am »
Thanks. That's what I figured out but wanted to be sure before I start parsing the XML. Definitely be something that should be added as part of the automation interface.
Do you know of the best way to determine the XML file location then?
I wouldn't want to "hardcode" the path even though it is probably a pretty standard one unless you changed the install folder...

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6817
  • Karma: +63/-7
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #3 on: June 12, 2019, 08:58:09 am »
If you're only interested in creating one (or a few) types of connectors, parsing technology files seems overkill. (And it won't work for internal technologies) The only reason I can think you would want to parse the files is if you wanted to provide a UI for every available technology stereotype.

What you want is the metatype, which you can see in the title of the properties dialog.

Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Archimate2::UsedBy");
(You could omit the namespace, but if you do, sooner or later your code will end up picking up the wrong stereotype)

If there is no metatype for the connector you want to create, you'll need to create the base type and then apply a stereotype. Again, both of these are visible in the UI.

Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Dependency");
myConnector.StereotypeEx="Archimate2::ArchiMate_UsedBy"
Eve

support@sparxsystems.com

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #4 on: June 12, 2019, 12:00:52 pm »
Hi,

I'm building a framework which would work for every type of the technology.
Parsing the XML file is no issue I do have handy APIs for that ;)
However I would like to be able to determine the location of the XML file programatically so that I can avoid hardcoding or putting in a config file the XML file's path.
If you know of a way to determine this it would be great.

Thanks

Phil

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2652
  • Karma: +41/-2
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #5 on: June 12, 2019, 12:22:29 pm »
Well there's...
  • MDGTechnologies folder
  • InternalTechnologies folder (encrypted)
  • The user's APPDATA folder
  • Stored internally in the model
  • On any one of the alternate paths that the user has defined
  • At a specified URL
  • Provided by an add-in at start-up
  • Anything I've missed...?
The Sparx Team
support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6852
  • Karma: +143/-103
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #6 on: June 12, 2019, 01:07:30 pm »
Well there's...
  • MDGTechnologies folder
  • InternalTechnologies folder (encrypted)
  • The user's APPDATA folder
  • Stored internally in the model
  • On any one of the alternate paths that the user has defined
  • At a specified URL
  • Provided by an add-in at start-up
  • Anything I've missed...?
Where's Wally?  ;D  ;D

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #7 on: June 14, 2019, 12:57:05 am »
Well there's...
  • MDGTechnologies folder
  • InternalTechnologies folder (encrypted)
  • The user's APPDATA folder
  • Stored internally in the model
  • On any one of the alternate paths that the user has defined
  • At a specified URL
  • Provided by an add-in at start-up
  • Anything I've missed...?

Yeah there are many possibilities, my wish is to understand how EA does figure out where to access the file so that I can do the same.
Any idea on how this is done? Since EA does load those files on startup, there must be a reference to the file location in a registry or in the database or in a one of EA's config file or the like...?

Thanks

Philippe

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9469
  • Karma: +266/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: "Clean" way to get MDG technology info
« Reply #8 on: June 14, 2019, 01:05:39 am »
The user specified locations are indeed stored in the registry.
The others are "fixed"

The problem might reading the technologies imported into the model (t_document) and the ones in the internalTechnologies.
You'll have to decode the format first.
The others are plain xml so you could read those, but I'm not convinced parsing the mdg xml's is the best approach.

Geert

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #9 on: June 14, 2019, 03:20:00 am »
The user specified locations are indeed stored in the registry.
The others are "fixed"

The problem might reading the technologies imported into the model (t_document) and the ones in the internalTechnologies.
You'll have to decode the format first.
The others are plain xml so you could read those, but I'm not convinced parsing the mdg xml's is the best approach.

Geert

Would you happen to know which registry key I'm supposed to look at? :)

Thanks

Phil

qwerty

  • EA Guru
  • *****
  • Posts: 10582
  • Karma: +232/-191
  • I'm no guru at all
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #10 on: June 14, 2019, 05:06:10 am »
HKEY_CURRENT_USER\Software\Sparx Systems

q.

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #11 on: June 14, 2019, 07:21:30 am »
No, there is no better way.
Either you parse the XML, or you hardcode all the info you need.

Or, and this is a long shot, you might be able to use the fully qualified stereotype in the AddNew() operations as the type parameter.
So something like
Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Archimate2::ArchiMate_UsedBy");(double check to make sure the syntax and names are correct)
Then you can check the type of the just created connector.

Not sure if this works, but it's worth a try.

Geert

Just as an FYI, this does not work. Would have been great though!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6817
  • Karma: +63/-7
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #12 on: June 14, 2019, 09:19:55 am »
Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Archimate2::ArchiMate_UsedBy");

Just as an FYI, this does not work. Would have been great though!

That's why I posted that you have to use the metaclass.
Code: [Select]
myConnector = myElement.connectors.AddNew("myName","Archimate2::UsedBy");
Eve

support@sparxsystems.com

P Robert

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: "Clean" way to get MDG technology info
« Reply #13 on: June 26, 2019, 07:23:17 am »
Just to close the loop, I've completed parsing the XML, retrieving the metaclass and creating the connector programatically.
That almost did the trick: stereotype was correctly applied but some other properties of the connector were not correctly set. Found out that in the "apply" XML tags there were some default property values configured.

<AppliesTo>
<Apply type="Association">
<Property name="direction" value="Unspecified"/>
<Property name="compositionKind" value="Aggregate at Source"/>
<Property name="_MeaningForwards" value="Aggregation of"/>
<Property name="_MeaningBackwards" value="Aggregates"/>
</Apply>
</AppliesTo>

I found out through the MDG Technology SDK about those Special Attributes (https://sparxsystems.com/enterprise_architect_user_guide/14.0/modeling_tools/supportedattributes_2.html) that could be defined and had to figure out for those that I were interested in how to apply them to the connector.

So more investigation than initially planned but it does work now  :)

Thanks for your help!