Author Topic: MDG - Create predefined tagged value types using DataType  (Read 7645 times)

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
MDG - Create predefined tagged value types using DataType
« on: January 24, 2024, 04:59:38 am »
Hi,

I have been able to create predefined Tagged Values using the UML Types / Tagged Value Types dialog and incorporate these into an MDG by giving an attribute on my stereotypes the same name as the TaggedValue. This however means that your tagged value must match the name of the UML Types tagged value and leads to for instance lots of Type=Date tagged values.

The documentation here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/modeling_frameworks/tag_types_data_type.html shows how you should be able to create a profile specific predefined tagged value using a dataType element in your profile e.g. a dataType element called DateProperty with notes field containing Type=Date;. You should then be able to assign this element as a type for your attribute e.g. EndDate:DateProperty.

I have tried to get this to work to no avail having followed the example, the stereotype MyDate should be of type DateProperty.
The profile XML contains:

   <Content>
      <Stereotypes>
         <Stereotype name="MyTest" notes="" cx="180" cy="70" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">
            <AppliesTo>
               <Apply type="Class">
                  <Property name="isActive" value=""/>
               </Apply>
            </AppliesTo>
            <TaggedValues>
               <Tag name="MyDate" type="" description="" unit="" values="" default=""/>
            </TaggedValues>
         </Stereotype>
      </Stereotypes>
      <TaggedValueTypes>
         <TaggedValueType property="DateProperty" description="" notes="Type=Date;"/>
      </TaggedValueTypes>
      <ViewDefinitions/>
      <Metamodel/>
   </Content>

Any pointers would be much appreciated.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8061
  • Karma: +118/-20
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #1 on: January 24, 2024, 11:20:44 am »
It looks like you haven't assigned the type to the attribute "MyDate", which means there is nothing to tie it to DateProperty.

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #2 on: January 24, 2024, 09:02:47 pm »
Eve,

I have assigned the type (DateProperty) to MyDate but it doesn't appear in the generated xml. If I update the xml to include a link to the DateProperty it still doesn't work after generating the MDG and importing the mts XML file.

I followed the linked article to try this.

Steve
« Last Edit: January 24, 2024, 10:26:17 pm by sjf »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #3 on: January 30, 2024, 01:34:50 pm »
Don't use the Tagged Value Types dialog, that's the old way of doing things. Instead, drop a DataType element from the toolbox onto the diagram, name it "DateProperty" and put "Type=Date;" in its notes. Then use it as the type of attributes in the <<stereotype>> classes.
The Sparx Team
[email protected]

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #4 on: January 30, 2024, 08:36:22 pm »
Hi KP,

I have followed this as per example and have done exactly as you have said. I haven't been able to get it to work consistently.
The profile includes the DateProperty in the list of tagged value types in the profile xml:

<TaggedValueType property="DateProperty" description="" notes="Type=Date;"/>

but the Stereotype attribute is missing the type="DateProperty":
<Tag name="End of Life Date"/>

Despite being in the attribute type - query from t_attribute:
Object_ID,Name,Scope,Stereotype,ID,Classifier,Type,
89105,End of Life Date,Public, ,441582,159795,DateProperty,



The only way I can get it to work is by using the Tagged Value Types dialog, which I don't like.

I have made a very simple example with two stereotypes, both with an attribute called Start Date of type DateProperty. One works the other doesn't. I have published the profile as a package:

<?xml  version='1.0' encoding='windows-1252' ?>
<UMLProfile profiletype="uml2">
   <Documentation id="456760C0-E" name="MyDate" version="1.0" notes="MyDate"/>
   <Content>
      <Stereotypes>
         <Stereotype name="AC" metatype="Application" notes="" cx="0" cy="0" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">
            <AppliesTo>
               <Apply type="Class">
                  <Property name="isActive" value=""/>
               </Apply>
            </AppliesTo>
            <TaggedValues>
               <Tag name="Start Date" type="DateProperty" description="" unit="" values="" default=""/>
            </TaggedValues>
         </Stereotype>
         <Stereotype name="MyDate1" metatype="MyDate1" notes="" cx="0" cy="0" bgcolor="-1" fontcolor="-1" bordercolor="-1" borderwidth="-1" hideicon="0">
            <AppliesTo>
               <Apply type="Class">
                  <Property name="isActive" value=""/>
               </Apply>
            </AppliesTo>
            <TaggedValues>
               <Tag name="Start Date"/>
            </TaggedValues>
         </Stereotype>
      </Stereotypes>
      <TaggedValueTypes>
         <TaggedValueType property="DateProperty" description="" notes="Type=Date;"/>
      </TaggedValueTypes>
      <ViewDefinitions/>
      <Metamodel/>
   </Content>
</UMLProfile>

and here is the output from SELECT * FROM t_attribute for these two attributes:

Object_ID,Name,Scope,Stereotype,Containment,LowerBound,UpperBound,ID,Pos,Classifier,Default,Type,ea_guid,StyleEx,
9640,Start Date,Private, ,Not Specified,1,1,2288,1,9635, ,DateProperty,{77BF1841-3816-4bed-B5EA-9712DBD7B6B6},volatile=0;,
9642,Start Date,Private, ,Not Specified,1,1,2292,1,9635, ,DateProperty,{EDF82B59-C9E4-4ad0-8E2A-B62EB69EF47F},volatile=0;,


« Last Edit: January 31, 2024, 12:09:44 am by sjf »

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #5 on: February 01, 2024, 02:07:49 am »
Well this is getting weirder, whether or not the DataType is included in the Profile for the MDG seems to depend upon the name of the stereotype that it is linked to.

I can change the name of the stereotype (F2) and sometimes the type="DataProperty" is populated and sometimes it isn't, though it is consistent.

The following names generate the right xml:
  • AC
  • Date2
  • Account
  • Application

The following don't produce the right output:
  • Anything begining with MyDate
  • Moon
  • Nightime
  • Process

I haven't discovered a pattern to this yet and would be interested if anyone can replicate this strange behaviour.

I'm using EA 16.1.1625 - 64 bit
« Last Edit: February 01, 2024, 02:09:35 am by sjf »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG - Create predefined tagged value types using DataType
« Reply #6 on: February 01, 2024, 02:32:47 am »
Have you checked if you have any tagged value types defined with any of these names?

Geert

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #7 on: February 01, 2024, 08:28:03 pm »
Hi Geert,

Yes I have checked that there are no tagged value types with this name (DateProperty or DateProp). I have also used strange stereotype names to try and exclude any that might be defined elsewhere.

Whether a stereotype is generated in the profile XML with the type defined seems to depend upon the name of the stereotype!! If I change the name of the stereotype in the MDG it sometimes generates the correct type, but I cannot find a pattern to help track this down.

I created a completely separate repository with just this very simple MDG in it to to test this.

Looks like I may have to go back to using tagged value types in my main MDG as this is the only way I can get this to work, though it is a pain as it will mean I will have to have a tagged value type for every differently named date attribute.

Thanks
Steve

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG - Create predefined tagged value types using DataType
« Reply #8 on: February 01, 2024, 10:47:20 pm »
Hi Steve,

Make sure to document this behavior and send in a bug report to Sparx.

If you can prove that it doesn't work in in a specific scenario, they will usually be happy to fix it.

Geert

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #9 on: February 08, 2024, 10:25:54 pm »
For anyone else who faces this issue, here's how I've managed to resolve it consistently:

1.) Ensure the dataType is in the same package
2.) Set the package to custom sort (CTRL + Down Arrow on an item)
3.) Ensure that all the dataTypes you have created are the last items in the package

Thanks
Steve

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG - Create predefined tagged value types using DataType
« Reply #10 on: February 08, 2024, 11:35:03 pm »
For anyone else who faces this issue, here's how I've managed to resolve it consistently:

1.) Ensure the dataType is in the same package
2.) Set the package to custom sort (CTRL + Down Arrow on an item)
3.) Ensure that all the dataTypes you have created are the last items in the package

Thanks
Steve

Good catch :). Did you report it as a bug to Sparx as well?

Seems like an easy enough fix

Geert

sjf

  • EA User
  • **
  • Posts: 25
  • Karma: +1/-0
    • View Profile
Re: MDG - Create predefined tagged value types using DataType
« Reply #11 on: February 09, 2024, 09:33:48 pm »
I created a simple qea file with one stereotype defined and two data types to demonstrate the issue and have now submitted a bug report.
Thanks
Steve