Book a Demo

Author Topic: Reading duplicate generalised attributes  (Read 3511 times)

AndrewW

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Reading duplicate generalised attributes
« on: June 11, 2012, 09:05:18 pm »
Dear All,
I’m creating some Jscript to read the extended (Generalised from other elements) attributes in a class element. This works well and I can pick up and work on the attributes ok.
The only issue is if the element I am reading the attributes from, generalises two or more other elements and the names of the attributes generalised  are the same in the elements I only see one via JScript, (Although the others can be seen when viewed in the EA GUI.

I have seen an attribute called AllowDuplicates, would this allow me to see all the generalised attributes, including those with the same name. If so how do I set the AllowDuplicates to allow this?
Kind Regards
Andrew






AndrewW

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Reading duplicate generalised attributes
« Reply #1 on: June 12, 2012, 05:06:01 pm »
No answers so far is this even possible?

Lets put this another way

If i have 3 classes each with a tag called MyTag and MyTag is set to Class1 for the 1st class
Class2 for the 2nd class
Class 3 for the 3rd Class

if Class 3 Generalises the other two classes, which can't I see all the tag values in class1, like I can if the tag names are different? What do I have to do to be able to see them?

Kind Regards
Andrew

AndrewW

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Reading duplicate generalised attributes
« Reply #2 on: June 12, 2012, 05:31:06 pm »
Bit more information. I know abotu the show duplicate tags option from the following URL
http://www.sparxsystems.com/uml_tool_guide/modeling_tool_features/showduplicatetags.htm

How ever even for the above example and using the EA sample code as a basis i can not see these values though the script. I have enclosed the script below


!INC Local Scripts.EAConstants-JScript

/*
 * Examples of how to access and use element extras - such as scenarios, constraints
 * and requirements.
 *
 * NOTE: Requires an element to be selected in the Project Browser
 *
 * Related APIs
 * =================================================================================
 * Element API - http://www.sparxsystems.com.au/EAUserGuide/index.html?element2.htm
 */
function ElementExtrasExample()
{
      // Show the script output window
      Repository.EnsureOutputVisible( "Script" );

      // Get the currently selected element in the tree to work on
      var theElement as EA.Element;
      theElement = Repository.GetTreeSelectedObject();
      
      if ( theElement != null && theElement.ObjectType == otElement )
      {
            var addedAttributeID = 0;

            Session.Output( "JScript ELEMENT EXTRAS EXAMPLE" );
            Session.Output( "=======================================" );
            Session.Output( "Working on element '" + theElement.Name + "' (Type=" + theElement.Type +
                  ", ID=" + theElement.ElementID + ")" );
            

            // ==================================================
            // MANAGE ELEMENT TAGGED VALUES
            // ==================================================
            Session.Output( "Tagged Values" );
            
            // Add a new tag
            var tags as EA.Collection;
            tags = theElement.TaggedValuesEX;

            
            
            // List all element tag
            for ( var i = 0 ; i < tags.Count ; i++ )
            {
                  var currentTag as EA.TaggedValue;
                  currentTag = tags.GetAt( i );
                  
                  Session.Output( "    Tag Name: " + currentTag.Name +"    Tag Value: " + currentTag.Value );
                  // Delete the tagged value that we just added
            }
            
            tags = null;            
            
      }      
}

ElementExtrasExample();

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Reading duplicate generalised attributes
« Reply #3 on: June 12, 2012, 05:48:03 pm »
Andrew,

There's probably a small bug in the implementation of the the property TaggedValuesEx, or it could even be intentional that they are hiding the duplicate tagged values.
What I would do is:
- send in a bug report to Sparx
- Get the tagged values from the generalized/specialized classes myself using the plain TaggedValues properties.

Geert

AndrewW

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Reading duplicate generalised attributes
« Reply #4 on: June 13, 2012, 05:02:01 pm »
Geert,
From point 2 I assume you mean follow the connection and grab he tags locally?? As the EX is the only way to see the values remotely.
Andrew

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Reading duplicate generalised attributes
« Reply #5 on: June 13, 2012, 06:03:37 pm »
indeed, that's what I meant.

Geert

AndrewW

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Reading duplicate generalised attributes
« Reply #6 on: June 14, 2012, 11:44:53 pm »
works thanks,
about 3/4 of a day to code
Andrew