Programmatically mapping between Classes and generated files

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Programmatically mapping between Classes and generated files

Postby Albert.Christensen@ngc.com » Thu Jul 29, 2021 4:23 pm

If the user has created a code engineering set, added several Class elements from the model into it, and generated code for them, how could a plugin then find the generated file for a given Class element?
Albert.Christensen@ngc.com
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Jun 23, 2020 1:40 pm

Re: Programmatically mapping between Classes and generated files

Postby Quentin.Cespedes@Samares-Engineering.com » Mon Aug 02, 2021 6:11 am

Hello,

If I understand well, you have generated a java file from a model, and you want to integrate this to your plugin?
There is maybe some other way, but we just integrate the java file into our plugin sources (do not forget to add the package line "package com.xxx.yyy.zzz.[...]).
Then using a static call (generatedJavaClass.subClassOrMethod or generatedJavaClass.getInstance(project).method) you will access to all the generated classes and methods.

I hope this will answer to your question

Quentin
Quentin.Cespedes@Samares-Engineering.com
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Mon Jun 24, 2019 7:58 am

Re: Programmatically mapping between Classes and generated files

Postby Albert.Christensen@ngc.com » Mon Aug 02, 2021 3:47 pm

Hi Qentin. That's not it.

In other words, I want to know how I should use the NoMagic OpenAPI to implement this method within a plugin:
Code: Select all
// Returns null if the user never added classInModel to the Code Engineering Set
public java.io.File findGeneratedFileInFilesystem(CodeEngineeringSet ces, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class classInModel) {
   //???
}


Thanks.
Albert.Christensen@ngc.com
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Jun 23, 2020 1:40 pm


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest