Extracting the compilation unit info [message #903693] |
Fri, 24 August 2012 19:40  |
Eclipse User |
|
|
|
Hi, all.
I have an XMI java model discovered by MoDisco but I need to extract the info the model is showing on the MoDisco Model Browser, as the image attached.
The code below loads the XMI file and I begin at the root model object: Dc3AdminEJB
Then I iterate over the 43 compilation units trying to know names like the real classes analized by the discoverer like the one in the image attached: BureauCharacteristicBO.java
Resource resource = resourceSet.getResource(uri, true);
System.out.println("Loaded " + uri + " " + resource);
ModelImpl rootModel = null;
for(EObject n : resource.getContents())
{
ModelImpl mo = (ModelImpl) n;
String rootModelName = mo.getName();
if(rootModelName.equalsIgnoreCase("Dc3AdminEJB"))
rootModel = mo;
}
if(rootModel != null)
{
System.out.println("Model: " + rootModel.getName());
EList<EObject> an = rootModel.eContents();
List<EClass> javaClasses = new LinkedList<EClass>();
for(EObject eo : an)
{
EClass eclass = eo.eClass();
String eclassName = eclass.getName();
//System.out.println("Java class: " + eclassName);
if(eclassName.equalsIgnoreCase("CompilationUnit"))
{
;
//CompilationUnit a = (CompilationUnit) eclass;
System.out.println("Java class: " + eclass.eResource());
javaClasses.add(eo.eClass());
}
}
}
The problem is that I keep getting the name CompilatioUnit not BureauCharacteristicBO, no matter what method I use.
Tried to cast to CompilationUnit class of the metamodel but it doesn't work:
org.eclipse.emf.ecore.impl.EClassImpl cannot be cast to javamm.CompilationUnit
Any advice on how to extract this info?
Thank you!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03748 seconds