Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » Changing KDM programatically
Changing KDM programatically [message #1059078] Thu, 16 May 2013 14:44 Go to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
Hello everyone I would like to know if it is possible to change the KDM programmatically. I mean, I have an instance of the KDM, which correspond a project in Java, then I would like to for instance "remove" a StorableUnit (a variable instance) to another ClassUnit, change the name of the ClassUnit, change the it from "public" to "private", and even create a MethodUnit programatically. Is that possible, if so, what should I use..

THanks in advance.
Re: Changing KDM programatically [message #1059089 is a reply to message #1059078] Thu, 16 May 2013 15:23 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

The Ecore implementation of KDM provided by MoDisco comes with the corresponding EMF-generated API (also in the same plugin).
Using this API, you will be able to handle (and modify) your KDM model programmatically while loaded in memory.

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Changing KDM programatically [message #1098085 is a reply to message #1059078] Fri, 30 August 2013 15:38 Go to previous messageGo to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
Could someone give me an example how to create an instance of ClassUnit programmatically?

THanks a lot.
Re: Changing KDM programatically [message #1098110 is a reply to message #1098085] Fri, 30 August 2013 16:21 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

You can find from the EMF API section of this tutorial, an example of use of an EMF generated API (as the KDM one is).
Another alternative is to use the EMF reflective API (cf. this example).

Best regards,


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Changing KDM programatically [message #1098158 is a reply to message #1098110] Fri, 30 August 2013 18:04 Go to previous messageGo to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
Hello thanks for helping. However, I still could do what I need.

I just need to know where/what is the class (KDMFactory.eINSTANCE.createClassUnit()) to create the ClassUNit class.

Could you help?
Re: Changing KDM programatically [message #1098161 is a reply to message #1098110] Fri, 30 August 2013 18:07 Go to previous messageGo to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
I tried to do something like that

ClassUnit classUnit = KdmFactory.eINSTANCE.create(ClassUnitImpl)


But the KdmFactory does not have a method named createClassUnit...

Someone knows how to instantiate a ClassUnit programmatically?
Re: Changing KDM programatically [message #1098306 is a reply to message #1098161] Fri, 30 August 2013 23:14 Go to previous messageGo to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
Hello guys, I have tried a lot but as you know the KDM model has many classes. Thus, I haven't already realized how to instantiate a KDM's class programmatically. Could someone give more details, Hugo, I know how to instantiate by using EMF, but I couldn't do for the KDM. I just need a little help Very Happy

[Updated on: Sat, 31 August 2013 00:02]

Report message to a moderator

Re: Changing KDM programatically [message #1099506 is a reply to message #1059078] Sun, 01 September 2013 21:05 Go to previous messageGo to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 72
Registered: September 2012
Member
Hello everyone.

I figured out how to instantiate the ClassUnit programmatically. You just need to use the Interface CodeFactory. For instance,
ClassUnit classUnit = CodeFactory.eINSTANCE.createClassUnit();
them you get a instance of it.


Thanks/
Re: Changing KDM programatically [message #1099892 is a reply to message #1099506] Mon, 02 September 2013 10:59 Go to previous message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

Good to see that you've solved your problem.

Best regards


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Previous Topic:KDM Method Invocation
Next Topic:Creating a Java Class Programmatically by means of Java Model
Goto Forum:
  


Current Time: Wed Apr 24 14:51:51 GMT 2024

Powered by FUDForum. Page generated in 0.04640 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top