Getting Value Properties From Block

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Getting Value Properties From Block

Postby jason.ferreira@navy.mil » Fri Sep 16, 2022 11:36 am

Hi,

I've got an instance specification and I can get the classifier(s) for that instance specification, but what I'm getting stuck at is how to get the value properties of that classifier (which is a Block).

For example,
Code: Select all
InstanceSpecification instSpec = some instance specification;
List<Classifier> clfier = instSpec.getClassifier();
for(Classifier c : clfier)
{
     List<ProertyValues> lstProps = c.getPropertyValues();  // <----- Is there some function or combination of functions to actually get the property values of this classifier?
}



We're using a Java plugin to attempt to grab the above info.

Does anyone have any ideas/suggestions on how to accomplish this?
jason.ferreira@navy.mil
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:0
Joined: Thu Dec 09, 2021 10:36 am

Re: Getting Value Properties From Block

Postby liam.neary@lmco.com » Fri Sep 16, 2022 12:42 pm

Hi Jason,

There a few different functions I've found that output a list of Attributes (getOwnedAttribute(), getFeature(), and getAttribute()). To be honest, I'm not quite sure what the difference between them is. If you only have value properties, you can just loop through them and access what you'd like (name, value, .etc) or if you have other properties too like part properties you can filter the value properties out by comparing the output of <Some Property>.getClassType(). For example, here are some of the class type strings that may be useful

PROPERTY_TYPE_STRING = "interface com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property";
CLASS_TYPE_STRING = "interface com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class";
DATA_TYPE_STRING = "interface com.nomagic.uml2.ext.magicdraw.classes.mdkernel.DataType";

Hope that helps!
liam.neary@lmco.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Fri Sep 16, 2022 12:18 pm

Re: Getting Value Properties From Block

Postby jason.ferreira@navy.mil » Mon Sep 19, 2022 8:16 am

Thanks Liam. It looks like .getAttribute() was what I was looking for.
jason.ferreira@navy.mil
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:0
Joined: Thu Dec 09, 2021 10:36 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests