|
| Re: How to process my KDM models [message #1005850 is a reply to message #1005842] |
Mon, 28 January 2013 23:02   |
keynne Belle Messages: 6 Registered: January 2013 |
Junior Member |
|
|
In order to write a request that allows me to get the KDM segment associated to my java project, i searched examples on the web and then i wrote the following query:
public class GetSegment implements IJavaModelQuery<Annotation, Segment> {
public Segment evaluate(final Annotation context, final ParameterValueList parameterValues)
throws ModelQueryExecutionException {
ResourceSet resourceSet=new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*",
new XMIResourceFactoryImpl());
resourceSet.getPackageRegistry().put(Resource.Factory.Registry.DEFAULT_EXTENSION,new XMIResourceFactoryImpl());
File fichierKDM = new File(Test.getProjectPath());
URI uri = URI.createFileURI(fichierKDM.getAbsolutePath());
Resource modelResource=resourceSet.getResource(uri, true);
Segment segment = (Segment) modelResource.getContents().get(0);
return segment;
}
}
But unfortunately, i got the following exception and i don't know how to fix it:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/MoDisco/kdm/kdm' not found. (file:/D:/MoDiscoWorkspace/MyModiscoProject/MyModiscoProject_kdm.xmi, 3, 16)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
at MyModiscoProject.GetSegment.evaluate(GetSegment.java:33)
at MyModiscoProject.Test.main(Test.java:16)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/MoDisco/kdm/kdm' not found. (file:/D:/MoDiscoWorkspace/MyModiscoProject/MyModiscoProject_kdm.xmi, 3, 16)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2591)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2422)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:242)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1511)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1290)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
... 3 more
|
|
|
| Re: How to process my KDM models [message #1006000 is a reply to message #1005850] |
Tue, 29 January 2013 09:13   |
Hugo Bruneliere Messages: 470 Registered: July 2009 |
Senior Member |
|
|
Hello,
The MoDisco Query Manager has been implemented in order to facilitate the creation of new queries in different languages, including notably Java.
Thus, when defining the body of the evaluate method, the context (i.e. the model element type the query is applied on) is already directly provided to you.
You don't have to implement any tentative access to files or EMF resources.
I encourage you to take a deeper look to the detailed MoDisco Reference Documentation (and its Query Manager section) to get more insights on this.
Generally, the MoDisco Documentation page (as available from the MoDisco homepage) is providing many different types of resources helping you to better understand the framework and its potential usages.
Best regards,
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
| Re: How to process my KDM models [message #1006201 is a reply to message #1006090] |
Wed, 30 January 2013 07:42   |
Hugo Bruneliere Messages: 470 Registered: July 2009 |
Senior Member |
|
|
A QuerySet is defined among a given metamodel, but can be applied on as many models as you want as long as these models conform to that metamodel.
In your case, defining your QuerySet among the KDM metamodel, you will be able to use its queries on all the KDM models that you can get from the analyzed projects.
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
| Re: How to process my KDM models [message #1006415 is a reply to message #1006328] |
Thu, 31 January 2013 05:02   |
Hugo Bruneliere Messages: 470 Registered: July 2009 |
Senior Member |
|
|
The current versions of the MoDisco Java & KDM discoverers only support the discovery from single projects.
The support for multiple projects as inputs may be developed and added in the future in MoDisco.
In the meantime, a quick fix is to specify yourself another KDM model simply referencing the root "Model" model elements coming from the different discovered models. Thus, loading this "integration" model should also load all the different referenced models.
Concerning your second point, KDM is defined to work at an abstraction level that is not going down to the method implementation details.
If you want models fully representing your projects (i.e. down to the methods internal implementation), you should rather use Java models obtained from the Java model discoverer.
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
| Re: How to process my KDM models [message #1006598 is a reply to message #1006415] |
Fri, 01 February 2013 01:48   |
keynne Belle Messages: 6 Registered: January 2013 |
Junior Member |
|
|
Hello. thanks again for the answers.
I'm working with the MoDisco distribution available with Eclipse Indigo. I attached a file showing all the discoverers that i found there. when i parse my kdm code model, i'm able to get some ActionElement of my java project. Nevertheless, when i invoke the "getOutBound" method on each of these ActionElement in order to get all their outgoing KDMRelationships, i always get a "null" value, whereas the MoDisco Model Browser indicates that my code model contains Calls going from the ActionElement contained in my project. So, i would like to know, if i'm not using the right method to get these outgoing KDMRelationships or if i there is an alternative to get them.
[Updated on: Fri, 01 February 2013 01:57] Report message to a moderator
|
|
|
| Re: How to process my KDM models [message #1006669 is a reply to message #1006598] |
Fri, 01 February 2013 06:27   |
Hugo Bruneliere Messages: 470 Registered: July 2009 |
Senior Member |
|
|
Looking to a KDM model opened into the MoDisco Model Browser, on an ActionElement the relationship to access to the Calls elements is named actionElement.
You could try to use this relation to get the Calls model elements.
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
|
Powered by
FUDForum. Page generated in 0.03192 seconds