I need all EObjects of one specific Class that are in the same directory or in a subdirectory.
I have a solution that seemded to work,
but it ignores at least one file.
The ignored file is loaded.
It appeard when the same method was called before in the program flow.
edit: The interesting part is that it works fine in the eclipse-Build. But It does not work in the headless build.
Right now I use the following:
public List<IEObjectDescription> getEObjectDescriptions(final Resource resource, final EClass eClass) {
final List<IEObjectDescription> descriptions = new ArrayList<>();
final IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(resource);
final IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(resource.getURI());
for (final IContainer c : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
for (final IEObjectDescription ob : c.getExportedObjectsByType(eClass)) {
descriptions.add(ob);
if (debug) { System.out.println("added ob: " + ob.getName()); }
if (ob.getName().toString().contains("MandantenBeziehungenBearbeiten")) {
System.out.println("ob added MandantenBeziehungenBearbeiten");
}
}
}
return descriptions;
}
andfinal Resource resource = module.eResource();
final List<IEObjectDescription> instanceDescriptions = getEObjectDescriptions(resource, eClass);
final ResourceSet resourceSet = resource.getResourceSet();
final String moduleDirPath = resource.getURI();
int i = 0;
for (final IEObjectDescription od : instanceDescriptions) {
i = i + 1;
final URI odUri = od.getEObjectURI();
final String odPath = resource.getURI()(odUri);
if (odPath.startsWith(moduleDirPath)) {
final EObject eObject = resourceSet.getEObject(odUri, true);
if (eObject instanceof StringNamed) {
stringNameds.add((StringNamed) eObject);
}
}
}
[Updated on: Mon, 30 June 2014 08:55] by Moderator