Brian,
I trust you are well again.
Following my victory of being able to save an emf, I am now up against not being able to query. I get the following error:
gogo: DiagnosticWrappedException: java.io.FileNotFoundException: /Users/gcr/Documents/ehrWorkspace/iop.storet.cmd (Is a directory)
This is with the same run configuration that succeeded when saving.
Some code:
URI uri = URI.createURI("mongodb://localhost/ehr/cda/527d0b740364b139f486fad8");
ResourceSetFactory resourceSetFactory = res.getResourceSet();
ResourceSet resourceSet = resourceSetFactory.createResourceSet();
Resource resource = resourceSet.getResource(uri, true); // This line throws the error.
--
You received this message because you are subscribed to the Google Groups "MongoEMF" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoemf+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
359> URI normalizedURI = normalize(uri);
Running your example the value of normalizedURI is
Running my stuff normalizedURI goes through a series of values:
Value 1 is as expected.
Values 2 and 3 are EMF bundles that I use and so must be loaded.
Value 4 appears to be the culprit. I points to the directory of the project from which the things were run and it corresponds to the error message. It does not occur in the document that was saved originally nor is it in the database so far as I can tell.
In both cases, your and mine, the following returns from the database DBObject correctly. (line 133). Trouble starts when we get to line 137. I recall you are saving URIs to the database so you can tell which EMF document was saved. Could the offending URI be getting saved? I dumped the collection in question, but did not find any URIs good or bad. Are they located elsewhere?
From:
MongoInputStream.loadResource...
133> DBObject dbObject = collection.findOne(new BasicDBObject(Keywords.ID_KEY, MongoUtils.getID(uri)));
137> EObject eObject = builder.buildEObject(collection, dbObject, resource, false);
EObjectBuilderImpl.buildFeatureMap(...
244> EStructuralFeature feature = (EStructuralFeature)
...
resource.getResourceSet().getEObject(URI.createURI((String) entry.get("key")), true);
...
At this point, the key is as follows:
entry.get("key") == "#///DocumentRoot/content"
MongoResourceSetImpl.getResource(URI uri, …
// uri == ""
...
93> URI normalizedURI = uriConverter.normalize(uri);
// normalizedURI == "file:/Users/gcr/Documents/erhWorkspace/iop.storet"
FileNotFoundException occurs because normalizedURI is a directory, which is what the error message says.
Can you shed any light on this business with #///DocumentRoot/content? It is not in the original document.
public static URI getURI(EObject eObject)
{
// If it's a proxy, use that.
//
URI proxyURI = ((InternalEObject)eObject).eProxyURI();
if (proxyURI != null) // This is null
{
return proxyURI;
}
else
{
// If it is in a resource, form the URI relative to that resource.
//
Resource resource = eObject.eResource();
if (resource != null) // This is null
{
URI uri = resource.getURI();
String uriFragment = resource.getURIFragment(eObject);
return uri == null ? URI.createURI("#" + uriFragment) : uri.appendFragment(uriFragment);
}
else
{
String id = EcoreUtil.getID(eObject);
if (id != null) // This is null
{
return URI.createURI("#" + id);
}
else
{ // Here we build the return value from fragments the last of which is DocumentRoot.
InternalEObject internalEObject = (InternalEObject)eObject;
List<String> uriFragmentPath = new ArrayList<String>();
HashSet<InternalEObject> visited = new HashSet<InternalEObject>();
for (InternalEObject container = internalEObject.eInternalContainer(); container != null && visited.add(container); container = internalEObject.eInternalContainer())
{
uriFragmentPath.add(container.eURIFragmentSegment(internalEObject.eContainingFeature(), internalEObject));
internalEObject = container;
}
StringBuffer result = new StringBuffer("#//");
// Here we assemble the return value in reverse order.
for (int i = uriFragmentPath.size() - 1; i >= 0; --i)
{
result.append('/');
result.append(uriFragmentPath.get(i));
}
return URI.createURI(result.toString());
}
}
}
}
private static String getText(FeatureMap root, String id) {
Stack<FeatureMap> stack = new Stack<FeatureMap>();
stack.push(root);
while (!stack.isEmpty()) {
FeatureMap featureMap = stack.pop();
for (FeatureMap.Entry entry : featureMap) {
if (entry.getEStructuralFeature() instanceof EReference) {
AnyType anyType = (AnyType) entry.getValue();
String attributeValue = getAttributeValue(anyType.getAnyAttribute(), "ID");
if (attributeValue != null && attributeValue.equals(id)) {
return getText(anyType.getMixed());
}
stack.push(anyType.getMixed());
}
}
}
return null;
}
On Wednesday, 13 November 2013 11:58:52 UTC-5, Geoffry Roberts wrote:From DBObjectBuilderImpl:
232 dbEntry.put("key", getFeatureURI(feature));
public String getFeatureURI(EStructuralFeature feature) {
String s = EcoreUtil.getURI(feature).toString();
if (s.startsWith("#///DocumentRoot")) {
ExtendedMetaData emd = new BasicExtendedMetaData();
s = emd.getNamespace(feature);
return s;
} else {
return s;
}
}