Book a Demo

Author Topic: Function (SQL UDF) - accessing in javascript  (Read 3985 times)

joelsatheesh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Function (SQL UDF) - accessing in javascript
« on: May 25, 2012, 05:44:50 am »
I have reverse engineered a model which has a few SQL server User Defined functions. EA automatically imported the code and assigned it as a <<function>> stereotype.
Now, Under a package I have about 20 functions. When I select the properties of each of this function, I can see the function code.

I'm writing a javascript to access the code associated each function, but I'm unable to. Below are the steps I followed - please guide me.

1. Accessed the package underwhich the functions exists.
Code: [Select]
     var thePackage as EA.Package;
      thePackage = Repository.GetTreeSelectedPackage();
2. Accessing an element (function) under this package
Code: [Select]
     var elements as EA.Collection;
      var element as EA.Element;
      elements = thePackage.Elements;
      element = elements.GetAt(1);
3. Now, I have to access the property of this element. The below output returns a count of 2
Code: [Select]
     var aColl as EA.Collection;
      aColl = element.Properties;
      Session.Output( "Count: "+ aColl.Count );
4. Now, when I try to get the 2 items that are part of the Properties (as below), I'm getting an error at "aColl.GetAt(i)" saying aColl.GetAt is not a function. But, the when I put a . after aColl, GetAt automatically shows up. Am I missing anything?
Code: [Select]
     var p as EA.PropertyType;
      for (var i=0; i<aColl.Count; i++) {
            p = aColl.GetAt(i);
            Session.Output( "Property Desc: "+ p.Name);
      }

Any help is appreciated Thank you,

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Function (SQL UDF) - accessing in javascript
« Reply #1 on: May 25, 2012, 08:40:56 am »
EA.PropertyType would be if you are iterating over Repostiory.PropertyTypes

Element.Properties is probably not what you want, and doesn't use the normal Collection class. (EA.Properties)

joelsatheesh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Function (SQL UDF) - accessing in javascript
« Reply #2 on: May 25, 2012, 11:20:59 pm »
Simon,
There ain't any EA.Properties class that I could use.
Is there any other option to access the Property of an element with stereotype "function". The reason I want to access is because it has the code (SQL function) - it would simplify my analysis a lot.
Thank you, Joel

joelsatheesh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Function (SQL UDF) - accessing in javascript
« Reply #3 on: May 26, 2012, 01:08:08 am »
In other words, how do I convert element.Properties into a primitive type? It certainly has 2 items in it (when I do a element.Properties.Count, I get a result of 2), but I don't know how to access them.
Thank you, Joel

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Function (SQL UDF) - accessing in javascript
« Reply #4 on: May 28, 2012, 09:26:20 am »
The type for Element.Properties is documented at  http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/properties2.html

The type of each item is described further down the page.