question-circle Recommendations needed

1 week 6 days ago #5424 by craae
I wonder what would be the best approach to become efficient and effective in writing Modelio Jython script code?

I'm trying to find an efficient way to identify available methods provided a certain Modeling object
For instance how to I query a modelling element for a specific property value?
Or How do I iterate a ModelRoot for properties that are defined and assigned to a specific modeltype? (In my case to for instance ArchiMate BusinessProcesses as the MetaClassReference in a construct similar to:

ModelRoot/Profile/MetaClassRefenrence/PropertyTableDefinition/Property


I'm currently trying to understand the Modelio API (just using scripting) by having both Eclipse and Modelio open at the same time, but I miss a feature like intellisense within the Modelio scripting editor or at least some documentation? (that I unfortunately havn't found)


My first script is just a bunch of print statements
# Test

print "Model"
Model = Modelio.getInstance().getModelingSession().getModel()
print Model
print "Roots (LibraryRoots): "
print Model.getLibraryRoots()
print "Roots (ModelRoots):"
print Model.getModelRoots()
print

modelingSession = Modelio.getInstance().getModelingSession()
print "Metamodel Extensions:"
print modelingSession.getMetamodelExtensions()
print

print modelingSession.getRequirementModel()
BPCollection  = Modelio.getInstance().getModelingSession().findByClass(BusinessProcess)
print BPCollection

for element in BPCollection:
	print element
	print element.getName()
	for prop in element.getProperties():
		print prop.getName()
		print prop
Attachments:

Please Log in or Create an account to join the conversation.

1 week 6 days ago #5426 by osl
Hi,

The Modelio metamodel user guide is available at this address:
http://www.modelio.org/documentation/metamodel-3.0/index.html

BR

Go pro

Please Log in or Create an account to join the conversation.

1 week 6 days ago #5427 by craae
Thanks appreciated, I have however been browsing that guide for a while, but unfortunately I haven't much experience in Jython scripting within Modelio.
So if possible I would be grateful if I could get a little more help/guidance - specifically on how to read out property values (own defined properties) on ArchiMate modeling Elements.

What would be the best approach to accomplish that?

I can find/retrieve the elements, but I really cannot figure out how to read/retrieve the property values. I have tried using the getProperty method but I'm probably providing the wrong arguments as I'm not retrieving any value...

Output from my trial Jython Script

# Test

print "Model"
Model = Modelio.getInstance().getModelingSession().getModel()
print Model
print "Roots (LibraryRoots): "
print Model.getLibraryRoots()
print "Roots (ModelRoots):"
print Model.getModelRoots()
print


modelingSession = Modelio.getInstance().getModelingSession()
print "Metamodel Extensions:"
print modelingSession.getMetamodelExtensions()
print

print modelingSession.getRequirementModel()
BPCollection = Modelio.getInstance().getModelingSession().findByClass(BusinessProcess)
print BPCollection

for element in BPCollection:
print "Element start:"
print "toString"
print element.toString()
print "getName:"
print element.getName()
print "getExtension:"
print element.getExtension()
print "getDependsOnDependency:"
print element.getDependsOnDependency()
print "getTag:"
print element.getTag()
print "getProperties(ID):"
print element.getProperties("fd5fdcd7-2d71-481f-84f2-e0954bc34c08")
print "getLocalProperties:"
print element.getLocalProperties()
print "getProperty: "
print element.getProperty("archimate", "Procestype")
print "getProduct:"
print element.getProduct()
print "getDescriptor:"
print element.getDescriptor()
print "getMatrix:"
print element.getMatrix()
print "Element slut:"
print
print "Element Properties:"
for prop in element.getProperties():
print prop.getName()
print prop


#for element in modelSession.getModel().getRoot(1).getOwnedElement():
# print element.getName

Model
org.modelio.api.impl.model.UMLModel@588d2e90
Roots (LibraryRoots):

Roots (ModelRoots):


Metamodel Extensions:
org.modelio.api.impl.model.MetamodelExtensions@6d8d78a

None

Element start:
toString
'Business Process'{b6c4b11d-7d14-41d7-8e98-e6c2d3a0a8b8} Archimate.BusinessProcess
getName:
Business Process
getExtension:
[]
getDependsOnDependency:
[]
getTag:
[]
getProperties(ID):
'fd5fdcd7-2d71-481f-84f2-e0954bc34c08'{e2d304ef-8213-41e2-8855-ba0b2fba49d6} Infrastructure.PropertyTable
getLocalProperties:
None
getProperty:
None
getProduct:
[]
getDescriptor:
[]
getMatrix:
[]
Element slut:

Element Properties:
fd5fdcd7-2d71-481f-84f2-e0954bc34c08
'fd5fdcd7-2d71-481f-84f2-e0954bc34c08'{e2d304ef-8213-41e2-8855-ba0b2fba49d6} Infrastructure.PropertyTable
Element start:
toString
'Business Process1'{b1e9c89a-ecfa-4775-a467-7a427bcd1fea} Archimate.BusinessProcess
getName:
Business Process1
getExtension:
[]
getDependsOnDependency:
[]
getTag:
[]
getProperties(ID):
'fd5fdcd7-2d71-481f-84f2-e0954bc34c08'{d90f8112-0529-4090-b843-fb8258f8194f} Infrastructure.PropertyTable
getLocalProperties:
None
getProperty:
None
getProduct:
[]
getDescriptor:
[]
getMatrix:
[]
Element slut:

Element Properties:
fd5fdcd7-2d71-481f-84f2-e0954bc34c08
'fd5fdcd7-2d71-481f-84f2-e0954bc34c08'{d90f8112-0529-4090-b843-fb8258f8194f} Infrastructure.PropertyTable

Please Log in or Create an account to join the conversation.

1 week 5 days ago #5428 by osl
Hi,

You can also use the 'Semantic model' to get an insight into model navigation.

Go to 'Views > Semantic model'
Then, in the Semantic view, activate the 'Synchronize' mode .





BR

Go pro
Attachments:

Please Log in or Create an account to join the conversation.

1 week 5 days ago #5429 by craae
Thanks I'm already using the semantic model viewer, and it's great! But it doesn't really help when you aren't certain how to use the API methods in matters of parameter passing

Please Log in or Create an account to join the conversation.

Moderators: andy
Time to create page: 0.251 seconds
^ Back to Top