- currentText = graph.getRelatedValue(resource, L0.PGraph_definition, Bindings.STRING);
- errorHappened = false;
- return new Document(currentText != null ? currentText : "");
+ if(graph.isInstanceOf(resource, L0.PGraph)) {
+ currentText = graph.getRelatedValue(resource, L0.PGraph_definition, Bindings.STRING);
+ errorHappened = false;
+ return new Document(currentText != null ? currentText : "");
+ } else {
+ Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(resource));
+ if(indexRoot != null && graph.isInstanceOf(indexRoot, L0.Ontology)) {
+ TransferableGraph1 tg = ModelingUtils.exportSharedOntology(graph, indexRoot, null, Constants.SHARED_LIBRARY_FORMAT, Constants.SHARED_LIBRARY_CURRENT_VERSION);
+ GraphRefactoringUtils.fixOntologyExport(tg);
+ currentText = PrettyPrintTG.print(tg);
+ errorHappened = false;
+ return new Document(currentText != null ? currentText : "");
+ }
+ throw new DatabaseException("Could not get PGraph from " + resource);
+ }