Author Topic: List of stereotypes in MDG  (Read 3636 times)

Pawel Jasinski

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
List of stereotypes in MDG
« on: February 16, 2012, 10:31:30 pm »
hi,

is there an api way to obtain list of stereotypes from MDG?
I am trying to avoid reading and parsing of the MDG file parallel to what EA does.

Cheers,
Pawel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: List of stereotypes in MDG
« Reply #1 on: February 17, 2012, 04:05:32 am »
If you happen to find it out let us know. Somewhere it must be hidden in EA's tables but neither t_stereotypes nor t_xrefs seems to hold that information. There must be some other secret door. (Except they parse each MDG on startup and hold it in local memory.)

q.

Michael Proske

  • EA User
  • **
  • Posts: 72
  • Karma: +0/-0
    • View Profile
Re: List of stereotypes in MDG
« Reply #2 on: March 06, 2012, 01:07:13 am »
I think it is in an internal memory table filled at startup. Definetely it is not copied in the internal database i have checked all tables in an empty ea file.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: List of stereotypes in MDG
« Reply #3 on: March 06, 2012, 04:03:13 am »
So the only way is to find out the loaded MDGs (must be somewhere in the registry since it is user based) and to parse the single XMLs yourself. Does not sound like something for the evening. More like for a couple of long winter nights...

q.

Michael Proske

  • EA User
  • **
  • Posts: 72
  • Karma: +0/-0
    • View Profile
Re: List of stereotypes in MDG
« Reply #4 on: March 07, 2012, 07:24:13 am »
A code to save time thats reads a s specific technology file and gets the stereotypes

        public void open()
        {
            //  XmlTextReader m_handle = new XmlTextReader(m_technology);

            m_xmlDoc = new XmlDocument();
            m_xmlDoc.Load(m_technologyName);
            m_stereotypeList = new List<Stereotype>();
            XmlElement root = m_xmlDoc.DocumentElement;

            XmlNodeList profiles = m_xmlDoc.SelectNodes("//UMLProfiles/UMLProfile/Documentation");
            foreach (XmlNode profile in profiles)
            {
                XmlNodeList stereotypes = profile.SelectNodes("../Content/Stereotypes/Stereotype");
                //Select Stereotype attribute
                foreach (XmlNode stereotype in stereotypes)
                {
                    XmlNode apply = stereotype.SelectSingleNode("./AppliesTo/Apply");
                    if ((apply != null) && apply.Attributes.GetNamedItem("type").Value == "ToolboxPage") continue;
                    Stereotype st = new Stereotype();
                    st.Technology = profile.Attributes.GetNamedItem("name").Value;
                    st.Name = stereotype.Attributes.GetNamedItem("name").Value;
                    if (apply != null) st.Apply = apply.Attributes.GetNamedItem("type").Value;
                    try
                    {
                        st.Generalize = stereotype.Attributes.GetNamedItem("generalizes").Value;
                    }
                    catch { }
                    XmlNodeList taggedValues = stereotype.SelectNodes(".//TaggedValues/Tag");
                    foreach (XmlNode tag in taggedValues)
                    {
                        st.taggedValues.Add(tag.Attributes.GetNamedItem("name").Value);
                    }
                    m_stereotypeList.Add(st);
                }
            }
        }

    public class Stereotype
    {
        public String Technology;
        public ArrayList taggedValues;
        public String Name;
        public String Apply;
        public String Generalize;

        public Stereotype()
        {
            taggedValues = new ArrayList();
        }
    }

It reads stereotypes and also the tagged values associated to it