| Creating a new discoverer [message #789809] |
Fri, 03 February 2012 07:35  |
porchrat Missing name Messages: 11 Registered: July 2010 |
Junior Member |
|
|
What I am trying to do is create a new Discoverer to attach a parser I have built previously onto it. I then want to get it to output some sort of standard model format I can look at like KDM or something (I am not that worried about what it outputs any of those standard modelling systems would do as this is just an initial test to give me an idea of how Modisco works).
I've found the API and a basic guide to creating a new Discoverer but I find myself confused. I have created this thread to add problems to as I encounter them in hopes that some of the experts using Modisco could maybe shed some light on them and speed me along.
Please forgive me if my questions are stupid questions. I am very new to Modisco and OSGI so I'm finding this all quite confusing.
OK so to my initial questions:
1) Why do I need Parameters in my Discoverer? What is their purpose?
I have read the API documentation on them and I am still confused. At first I thought things like this:
private String myParamIn;
@Parameter(name="PARAM_IN")
public void setMyParamIn(final String value) {
this.myParamIn = value;
}
were just there to help set the source file up to be discovered but that doesn't make sense because the basicDiscoverElement(IFile source, IProgressMonitor monitor) method has a "source" parameter right there.
2) Is there a separate class dealing with output formatting so that as I identify the various statements (e.g. 'if' statements) in my source I can add those elements to the model or do I have to build a class for this myself?
|
|
|
| Re: Creating a new discoverer [message #789962 is a reply to message #789809] |
Fri, 03 February 2012 11:17   |
Fabien Giquel Messages: 134 Registered: July 2009 |
Senior Member |
|
|
Hi,
thank you for your interest in MoDisco and Eclipse components. I will try to help you :
1)
the framework makes the assumption that a discovery process has always one main source represented as an IFile instance.
Annotations @Parameter are here only for additional parameters if needed. You may ignore them.
2)
I am not sure to understand when you say "...dealing with output formatting...I can add those elements to the model". Can you explain a little more ? The usual way to complete your output model is to create model element instances using org.eclipse.emf.ecore.EFactory/EPackage subclasses instances associated to your metamodel.
Regards,
Fabien.
----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
|
|
|
| Re: Creating a new discoverer [message #791781 is a reply to message #789962] |
Mon, 06 February 2012 03:54   |
porchrat Missing name Messages: 11 Registered: July 2010 |
Junior Member |
|
|
Hi Fabien.
Thank you for the response.
Fabien Giquel wrote on Fri, 03 February 2012 11:17Hi,
thank you for your interest in MoDisco and Eclipse components. I will try to help you :
1)
the framework makes the assumption that a discovery process has always one main source represented as an IFile instance.
Annotations @Parameter are here only for additional parameters if needed. You may ignore them.
Ah excellent that makes perfect sense.
Quote:2)
I am not sure to understand when you say "...dealing with output formatting...I can add those elements to the model". Can you explain a little more ? The usual way to complete your output model is to create model element instances using org.eclipse.emf.ecore.EFactory/EPackage subclasses instances associated to your metamodel.
Regards,
Fabien.
Sorry I am clearly not doing a great job of explaining myself here.
If I have this right a Discoverer runs through a source (in this case an IFile instance) and extracts key phrases and other structures that have meaning to it. It parses it basically. Then those key phrases need to be stored in the form of some sort of model (for example a KDM source model as an xmi file).
My question is this: If we are outputting to some sort of standard KDM source model format is there some sort of class that facilitates that? Presumably it would have some methods for adding elements to the KDM source model, creating associations between elements, handling ownership and group behaviours etc.
Basically this is what I am trying to do:
I have a parser that I use for a specific language (a form of BASIC). I want to create a Discoverer that uses this parser to find keywords in the language and then take those keywords and create a KDM source model (or something similar).
I would actually prefer it if that KDM source model weren't stored in an xmi file but instead were stored in some sort of RDBMS such as MySQL. Scale is an issue and if the entire model were stored in xmi I doubt it would be manageable.
Is this sort of thing possible at the moment using Modisco?
[Updated on: Mon, 06 February 2012 04:01] Report message to a moderator
|
|
|
| Re: Creating a new discoverer [message #792118 is a reply to message #791781] |
Mon, 06 February 2012 11:33   |
Fabien Giquel Messages: 134 Registered: July 2009 |
Senior Member |
|
|
Hi,
MoDisco does not provide particular helper for creating KDM model instances, or other. You should use the EMFgenerated EPackage and EFactory implementations related to the metamodel.
Note : KDM has many subpackages for several domains. "KDM.Source" deals with files representation. "KDM.Code" deals with code artefacts & types.... May be "KDM.Source" will not be the one that fits your target.
MoDisco relies on EMF for model management and does not provide particular mechanism for saving step. What you need to know in your case is :
- your discoverer impl should extend "AbstractModelDiscoverer"
- you should override "saveTargetModel()" which has some XMI/URI specific code.
- it would be logical also to override "createTargetModel()" for creating a Resource instance other than a XMIResourceImpl one. An idea would be to write some RDBMSResourceImpl with related load/save method. Another idea is to rely on Eclipse CDO framework for targetting scalibility.
Regards,
Fabien.
----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
|
|
|
|
|
| Re: Creating a new discoverer [message #797248 is a reply to message #795275] |
Mon, 13 February 2012 03:24   |
Fabien Giquel Messages: 134 Registered: July 2009 |
Senior Member |
|
|
Hi,
may be i did not say the essential thing about kdm metamodel implementation :
the "org.eclipse.gmt.modisco.omg.kdm" plugin contains the Java implementation for kdm metamodel and its subpackages.
If you set it as a required plugin of your new discoverer plugin project, you will have access to public Java API for creating KDM models (among them the org.eclipse.gmt.modisco.omg.kdm.code.CodeFactory class for code subpackage).
Hoping that is the information you are looking for.
Fabien.
----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
4, rue du Château de l'Eraudiere
44324 NANTES CEDEX 03
----------------------------------------------------
|
|
|
|
Powered by
FUDForum. Page generated in 0.01833 seconds