|
Re: How to process my KDM models [message #1005850 is a reply to message #1005842] |
Tue, 29 January 2013 04:02 |
keynne Belle Messages: 30 Registered: January 2013 |
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 #1006598 is a reply to message #1006415] |
Fri, 01 February 2013 06:48 |
keynne Belle Messages: 30 Registered: January 2013 |
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 06:57] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03614 seconds