Read referenced resource programatically [message #634605] |
Fri, 22 October 2010 12:30 |
Kai Maschke Messages: 16 Registered: October 2010 |
Junior Member |
|
|
Hi there,
I figured out how to reference another ecore model inside an ecore model. the generated editor code works fine. I am able to use the editor to reference the other ecore instance.
But I want to load the instances programtically. All works fine for me as long as I load a simple instance which references no other one. If I try it like this below, the referenced instance content is not loaded.
File dir = new File(path);
File[] files = dir.listFiles();
List<Datasource> sources = new ArrayList<Datasource>();
for (File aFile : files) {
try {
if (!aFile.getAbsolutePath().toString().endsWith("datasource")) {
continue;
}
@SuppressWarnings("unused")
DatasourcePackage pack = DatasourcePackage.eINSTANCE;
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
"datasource", new XMIResourceFactoryImpl());
URI fileURI = URI.createFileURI(new File(aFile
.getAbsolutePath()).getAbsolutePath());
Resource myPort = rs.getResource(fileURI, true);
Datasource source = (Datasource) myPort.getContents().get(0);
sources.add(source);
} catch (Exception e) {
e.printStackTrace();
}
}
So what do I have to do, to get the referenced content being loaded?
[Updated on: Fri, 22 October 2010 12:30] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04394 seconds