Author Topic: Modify Archimate3 MDG to display tagged values  (Read 20551 times)

NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Modify Archimate3 MDG to display tagged values
« on: April 10, 2021, 11:50:21 am »
Hi, I am attempting to modify Archimate3 MDG to display tagged values but so far I have not been successful. I have done the following so far
1) Followed the instructions in https://sparxsystems.com/resources/user-guides/15.2/modeling/mdg-technologies.pdf to create a profile, using a copy of archimate3.xml MDG file from C:\Program Files...\MDGTechnologies folder, created the stereotype helper and added the following shapescript to display the tagged value.
2) I then exported the profile as a xml and combined it manually with the copy of archimate.xml since I couldn't figure out how to merge the profile.xml I created with the archimate3.xml through sparx.
3) Finally I imported the updated archimate.xml file into a new model and created a new diagram with the archimate element but the tag value didn't come and and it wasn't displayed. Even the line that I coded into the shapescript didn't come through. I am not able to figure out what step I am missing.

shape main
{
       DrawParentShape();

       MoveTo(0,0);
       LineTo(100,100);
 
       if (HasTag("Database"))
       {
             Println ("#TAG:Database main");
       }
}
 
//Shape ChildElement adds Child Compartments to the parent.
shape ChildElement
{
       if (HasTag("Database"))
       {
             SetCompartmentName("Tags");
             Println ("#TAG:Database#");
             Println ("Database tag compartment");
       }
}

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #1 on: April 11, 2021, 07:12:40 am »
Hard to tell without seeing. Println ("#TAG:Database main"); misses a closing # at least. Also, why check to Database and then print Database main?

q.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1320
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #2 on: April 11, 2021, 09:36:43 am »
Yes the process of customising Sparx EA isn't for the faint hearted together with a document with 230 odd pages it can be a bit daunting. Sparx EA is not the easiest of tools to customise. As well as the points Qwerty spotted looking at your method I suspect step 2) and 3) are other sources of your problem. You don't need merge the profile or import the xml. You need to create another MDG with your profile in it and  point Sparx EA to it to pick it up.

...
2) I then exported the profile as a xml and combined it manually with the copy of archimate.xml since I couldn't figure out how to merge the profile.xml I created with the archimate3.xml through sparx.
3) Finally I imported the updated archimate.xml file into a new model and created a new diagram with the archimate element but the tag value didn't come and and it wasn't displayed. Even the line that I coded into the shapescript didn't come through. I am not able to figure out what step I am missing.
...
I think the way to do it is you create another MDG called ArchiMateExtension.mdg with your profile in it rather than merge.

These are the rough steps I'd try to get that to work.
  • Create Stereotype Profiles using Profile Helpers - page 103 to107
  • But redefine the stereotype following instructions on p30 and add your script and tagged values
  • Save the diagram as a stereotype profile.
  • Generate MDG with stereotype profile- p119  You could call the new MDG ArchiMateExtension.mdg for example
  • Set up sparx EA to point to the MDG profile via tab Specialise Tab>MDG Technologies, Click Advanced.. button and add path to MDG
  • Sparx EA should read the new MDG and redefine the ArchiMate element with your new shapescript and tagged values
when you create new ArchiMate element the redefined script and tagged values should be added after that.
Well that's the theory off the top of my head as I've not tested redefining stereotypes so there may be more to it but hopefully that gets you one step closer to making it work. You may have to specify ArchiMate MDG is required too and thats in the manual.
« Last Edit: April 11, 2021, 05:27:34 pm by Sunshine »
Happy to help
:)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Modify Archimate3 MDG to display tagged values
« Reply #3 on: April 11, 2021, 04:21:41 pm »
I agree with Sunshine. You shouldn't try to merge MDG files like that.
Follow the instructions to redefine stereotypes https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html

And don't forget to set your MDG as the "active" one.

Geert

NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #4 on: April 11, 2021, 10:13:59 pm »
Hard to tell without seeing. Println ("#TAG:Database main"); misses a closing # at least. Also, why check to Database and then print Database main?

q.

Hi qwerty, thanks for your response. The print in the main was just for me to see which parts of the shapescript are triggered and which are not, just for debugging purposes :-)

Yes the process of customising Sparx EA isn't for the faint hearted together with a document with 230 odd pages it can be a bit daunting. Sparx EA is not the easiest of tools to customise. As well as the points Qwerty spotted looking at your method I suspect step 2) and 3) are other sources of your problem. You don't need merge the profile or import the xml. You need to create another MDG with your profile in it and  point Sparx EA to it to pick it up.

I agree with Sunshine. You shouldn't try to merge MDG files like that.
Follow the instructions to redefine stereotypes https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html

And don't forget to set your MDG as the "active" one.

Geert

Hi Sunshine and Geert, thanks for your responses to my question as well. I will follow your guidance and post a response if I run into any additional issues.

NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #5 on: April 12, 2021, 02:50:02 am »
Hi Sunshine and Geert, thanks for your responses to my question as well. I will follow your guidance and post a response if I run into any additional issues.

Hi Sunshine and Geert, I followed your guidance but I was unable to complete the below step from the Sparx EA document. Specifically I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me - I am on version 15.1 not sure if that is the limiting factor. In any case I decided to leave the relationship as Generalization and completed all remaining steps like you guys mentioned including making the new MDG as active but still no success. I do see a stereotype of "Archimate3_Specialization" to apply to the generalization which I will try next and see if that yields the desired results. If you have any additional thoughts or ideas please do let me know.

Create a Stereotype element with the same name, not fully-qualified. See 'Principle' in the example.
Draw a Generalization from the redefining stereotype to the redefined stereotype, and give the
Generalization the <<redefines>> stereotype.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #6 on: April 12, 2021, 09:04:59 am »
I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me
Unfortunately, that stereotype doesn't exist in any profile or by default in the model. In the stereotype dialog click 'New...' and type redefines. If you don't have permission to do that, get someone else to do it for you.

Yes, it has been added to EAUML profile for a future version.

NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #7 on: April 12, 2021, 11:50:17 pm »
I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me
Unfortunately, that stereotype doesn't exist in any profile or by default in the model. In the stereotype dialog click 'New...' and type redefines. If you don't have permission to do that, get someone else to do it for you.

Yes, it has been added to EAUML profile for a future version.

Hi Eve, thanks for this tip. I was able to make progress. I was able to successfully create the profile, publish the MDG, and import the MDG into a new project. I am not able to select the tag name that I created in my profile but I was able to see a part of the shapescript execute. I say only a part since I added some debugging prints which I am able to see. I added a tag value manually but I don't see the compartment for the tag so I need to dig a little further. Also for some reason the archimate elements that I modified are showing a different color (orange) vs the normal green (for technology elements) or blue (for application elements)
Please let me know if anyone has any tips or suggestions.
« Last Edit: April 12, 2021, 11:53:28 pm by NewToSparxEA »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Modify Archimate3 MDG to display tagged values
« Reply #8 on: April 13, 2021, 01:06:53 am »
The color is probably due to the options selected when generating the UML profile.

A new tagged value added to your redefining stereotype should show up in the properties window (not on the diagram)

Geert

NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #9 on: April 13, 2021, 02:23:20 am »
The color is probably due to the options selected when generating the UML profile.

A new tagged value added to your redefining stereotype should show up in the properties window (not on the diagram)

Geert

Thanks Geert. I see it now and after selecting a value from the drop down additional debugging print statements I added in the shapescript are being triggered. My shapescript to display the tag compartment is still not working.

shape main
{
       DrawParentShape();

       MoveTo(0,50);
       LineTo(100,100); //adding this line just to see if shapescript is executing - it is working for me
 
       if (HasTag("Database")) //checking if the tag exists
       {
             Println ("#TAG:Database main"); //this print is working as soon as I select a value from the drop down
       }
      
}

//the below is not executing

//Shape ChildElement adds Child Compartments to the parent.
shape ChildElement
{
      SetCompartmentName("Tags"); //this is to see if the tags compartment name is being added but it's not

      if (HasTag("Database"))
       {
             SetCompartmentName("Tags-New"); // this is to see if the script finds the tag Database
             Println ("#TAG:Database#"); //to display the tag name
       }
}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Modify Archimate3 MDG to display tagged values
« Reply #10 on: April 13, 2021, 03:45:51 am »
Have you tried your shapescript on a regular new stereotype?
I know these compartments are a bit of a fuss to get right.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #11 on: April 13, 2021, 05:30:09 am »
For me it worked. You probably have no child elements with that tag. Again: without seeing it's all guess work.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #12 on: April 13, 2021, 10:00:34 am »
The ChildElement shape script will only be called if the element is drawing compartments, which it won't be because the ArchiMate shape script doesn't. Additionally, it's not doing what you think it is. It's called once for each element owned by the parent, so if the compartments where being shown I suspect you would end up displaying the contents of the tag database for each of the child elements. Not the element you are drawing.

I would start by drawing the native rectangle notation, which will then allow you to enable the tagged value compartment.
Code: [Select]
shape main
{
layouttype="border";
noshadow=true;

if(hasproperty("rectanglenotation","0"))
{
DrawParentShape();
}
else
{
DrawNativeShape();
}
}


NewToSparxEA

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #13 on: April 14, 2021, 03:25:44 am »
The ChildElement shape script will only be called if the element is drawing compartments, which it won't be because the ArchiMate shape script doesn't. Additionally, it's not doing what you think it is. It's called once for each element owned by the parent, so if the compartments where being shown I suspect you would end up displaying the contents of the tag database for each of the child elements. Not the element you are drawing.

I would start by drawing the native rectangle notation, which will then allow you to enable the tagged value compartment.

Hi Eve, thank you so much!! This worked great and the tags are displayed. The minor UI issue is that the elements have overlapping icons other than that the tags are displayed!! Please see image below. Is there any way to fix the overlapping icons?

https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png
« Last Edit: April 14, 2021, 03:46:05 am by NewToSparxEA »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Modify Archimate3 MDG to display tagged values
« Reply #14 on: April 14, 2021, 08:30:43 am »
Unfortunately there isn't any way to fix that. You can't prevent the decoration from the ArchiMate shape script from being drawn and DrawNativeShape means that you get all of the native drawing.