Getting contained models in Jython

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Getting contained models in Jython

Postby Bill Watkins » Mon Aug 06, 2007 10:13 am

I would like to be able to get to the models contained by a model in a
Jython script, but I'm having problems understanding how to apply the
examples from pages 5-30 to 5-32 of the OpenAPI manual to the Jython
scripting environment. Can you suggest how to apply the iterators in
Jython?

Thanks,
Bill Watkins


Bill Watkins
 
Posts Rating:

Re: Getting contained models in Jython

Postby Thanadee Ujjubandh » Tue Aug 07, 2007 2:53 am

Dear Bill,

Below is the example how to iterator in Jython for getting attribute and
method of class.

#Creating HashSet for removing same Class reference.
refAllOfClass = HashSet()

#Getting all classes and creating block for all classes from all
selected packages.
for packageID in reportConfig.packageIDs:

refAllOfClass.addAll(GlobalConfigValues.CommonValues.MD_DATA.getPackageElement(project,
packageID, "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class"))

for classInstance in refAllOfClass: #<----------- for [varabile] in
[collection]:
tmp = String(classInstance.getHumanName())
name = tmp.substring(tmp.indexOf(" ")+1,tmp.length())

for attribute in classInstance.getAttribute(): #<----------- for
[varabile] in [collection]:
tmp = String(attribute.getHumanName())
attributeName = tmp.substring(tmp.indexOf(" ")+1,tmp.length())

for method in classInstance.getOwnedOperation(): #<----------- for
[varabile] in [collection]:
tmp = String(method.getHumanName())
methodName = tmp.substring(tmp.indexOf(" ")+1,tmp.length())

Best Regards.

Teerawat Chaiyakijpichet
Analysis Manager
No Magic Asia
(Asian Software Development Center)
719 KPN Tower, 22nd Floor, Huaykwang,
Bangkapi, Bangkok 10310 Thailand
Phone: + 66 2717-0250
Fax: + 662 717-0251
Email: teerawat_c <mailto:teerawat_c>
WWW: http://www.nomagicasia.com

nntp://news.nomagic.com/nomagic.products.magicdrawuml.openapi wrote:

>I would like to be able to get to the models contained by a model in a
>Jython script, but I'm having problems understanding how to apply the
>examples from pages 5-30 to 5-32 of the OpenAPI manual to the Jython
>scripting environment. Can you suggest how to apply the iterators in
>Jython?
>
>Thanks,
>Bill Watkins
>
>
>
>
>


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Thanadee Ujjubandh
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests