Author Topic: can't get tagged values into profiles  (Read 4464 times)

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
can't get tagged values into profiles
« on: March 12, 2009, 09:26:23 pm »
Hi everybody,

I have developed a profile. Some profile's classes have attributes. I saved it into xml and imported it.

When I click on a profile element (Resources window) and drag it into the diagram, I get a element with all tagged values, corresponding to the original attributes. It works fine ...

However, when I try to generate elements via Automation interface, the tagged values do not appear...

I call the following method:
Code: [Select]
       public static EA.Element createElement(EA.Package aParentPackage, string aElementName,
string aElementType, string [highlight]aElementStereotype[/highlight])
        {
            EA.Element newElement = (EA.Element)aParentPackage.Elements.AddNew(aElementName, aElementType);                        
            newElement.Stereotype = aElementStereotype;
            newElement.Update();
            aParentPackage.Elements.Refresh();

            return newElement;
        }

and I provide the name of the class from the profile package as a "[highlight]aElementStereotype[/highlight]"

Could someone give me a hint, why tagged values do not appear in this case?

... May be the EA does not map my generated elements to the profile correctly ...



« Last Edit: March 12, 2009, 09:29:58 pm by xhanness »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: can't get tagged values into profiles
« Reply #1 on: March 12, 2009, 10:16:15 pm »
I'm not sure you should be using the Resources window at all. See the documentation on profiles - or search the forum - for the newer method of loading these. It has been the default implementation since EA 7.0 came out.

Even so I think you will still have your problem with automation. Try this:

Change your code so that the profile string is in the form <profile name>::<stereotype>. Something like MyProfile::MyStereotype. You would quote the entire string of course. You are (sort of) providing a fully-qualified string in place of (just) a stereotype name.

There are some things you should be aware of. In no particular order:
  • All components of the string are case sensitive (no surprise here, as UML has always treated stereotypes this way).
  • (AFAIK) You cannot 'extend' this concept to additional levels; there is no 'nested' profile paradigm (at least in EA at this point).
  • The profile name part of the string is one of the properties you supply during the creation process. I don't remember which field and dialog it is found on, but you will know when you see it. [It is the 'shorter' version.]
  • Remember to use a double colon; this is very easy to forget, and the default typeface does not help any. Pretty much everyone falls afoul of this, and EA fails silently (i.e. there is no error message). When (not if) you don't get results, check this first.
HTH, David

[edit]But see Frank's post below.

Note that this will take you into undocumented territory - at least as of EA 7.1. We'll see if 7.5 either documents (and stabilizes) this, or provides another way.[/edit]
« Last Edit: March 12, 2009, 10:42:15 pm by Midnight »
No, you can't have it!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: can't get tagged values into profiles
« Reply #2 on: March 12, 2009, 10:31:35 pm »
Haven't tried it for a while, but the situation used to be that tagged values defined in profiles would never be automatically added to elements created by API. There used to be a synchronizing method though:

http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1203483841/4#4


xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: can't get tagged values into profiles
« Reply #3 on: March 12, 2009, 11:13:15 pm »
Hi gyus !

thanks for your helpful answers ... I got the elements sychnronized with my profile and tagged values are present.


The right solution was THIS

Code: [Select]
aRepository.CustomCommand("Repository", "SynchProfile", "Profile=PPP;Stereotype=SSS");

The stereotype name is enough to provide without namespace.

thanks !
 :)


lubos

  • EA User
  • **
  • Posts: 101
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: can't get tagged values into profiles
« Reply #4 on: April 02, 2009, 11:00:58 pm »
The problem I see is that you have to know the name of the profile, which is not very general.
We have solved this problem by this code in plugin:
Code: [Select]
oreach (FileInfo fi in di.GetFiles("*.xml"))
                {
              
                    XPathDocument xdoc = new XPathDocument(fi.FullName);
                    XPathNavigator xnav= xdoc.CreateNavigator();
                    String[] stereotypes = elem.StereotypeEx.Split(',');
                    foreach (String stereotype in stereotypes)
                    {
                  
                        XPathNodeIterator xiter = xnav.Select("/MDG.Technology/UMLProfiles/UMLProfile/Content/Stereotypes/Stereotype[@name='"+stereotype+"']/TaggedValues/Tag");
                        while (xiter.MoveNext())
                        {
                        
                            String def= xiter.Current.GetAttribute("default", "");
                            if (def == String.Empty) def = "";
                            String name = xiter.Current.GetAttribute("name", "");
                            if (name == String.Empty) name = "xxxnamexxx";
                            CommonUtils.setTaggedValue(elem, name, def);
                        }
                    }

                }

that parses the MDG xml file and looks for definitions of the given stereotype and automatically adds the requirred tagged values to the element.

The advantage I see is you can add new UML profiles without modifying the plugin.

Any other ideas?

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: can't get tagged values into profiles
« Reply #5 on: November 10, 2009, 10:54:13 am »
Quote
Hi gyus !

thanks for your helpful answers ... I got the elements sychnronized with my profile and tagged values are present.


The right solution was THIS

Code: [Select]
aRepository.CustomCommand("Repository", "SynchProfile", "Profile=PPP;Stereotype=SSS[highlight];[/highlight]");

The stereotype name is enough to provide without namespace.

thanks !
 :)

There was a missing semi-colon, which I have highlighted. HTH
The Sparx Team
[email protected]

Timbo

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: can't get tagged values into profiles
« Reply #6 on: October 01, 2010, 06:19:19 pm »
Hi,
Is there an issue with synchronizing operations. I have the synchronize working fine with stereotypes that are classes but i have an issue with operations. When i add in code they do not synchronise. If i then go to diagram and save them as a dif stereotype then save them back to normal stereotype they do sync. Code below shows how i add it which is the same as for the elements, so im not sure how to fix this issue. Any ideas?


Code: [Select]
       
        var MatchingRuleOp as EA.Method;
        MatchingRuleOp = ResponseRuleElement.Methods.AddNew(  "MatchAll" , "");
        MatchingRuleOp.Stereotype = "DP_MatchingRule";
        MatchingRuleOp.Update();
     thePackage.Elements.Refresh();
     Repository.CustomCommand("Repository", "SynchProfile", "Profile=DataPower;Stereotype=DP_MatchingRule;");