[
https://issues.apache.org/jira/browse/STANBOL-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474935#comment-13474935
]
Alessandro Adamou commented on STANBOL-710:
-------------------------------------------
The Ontology Manager API has a few types of objects, such as Scope,
OntologySpace and Session, that reference ontologies stored in Stanbol.
These objects also need to be exported as ontologies (e.g. ontologies with OWL
import declarations, or merged axioms from all the referenced ontologies). This
is very useful when you GET a REST resource representing a scope, session etc.
and accept RDF/XML, or Turtle, or Manchester OWL Syntax etc.
To do so I make them implement this OWLExportable interface which looks like
this
public interface OWLExportable {
<O> O export(Class<O> returnType, boolean merge, IRI prefix);
// ... a few more methods
}
So if I have a
Session s1;
IRI prefix = IRI.create([stanbol-host]"/ontonet/session");
then I can call
OWLOntology o = s1.export(OWLOntology.class, false, prefix);
so I have a Session represented as an OWL API OWLOntology (good for OWL/XML,
Manchester and Functional syntax formats, but also a prettyprint for RDF/XML
and Turtle). And it contains owl:imports triples whose objects start with
prefix.
Other times I need a Clerezza TripleCollection because I can use it for
RDF/JSON, JSON-LD and faster RDF/XML and Turtle serialization. So I'll do
TripleCollection o = s1.export(TripleCollection.clas, false, prefix);
(internally the implementation uses a SimpleMGraph or IndexedMGraph);
Now, currently I have the export() method implementation in the ScopeImpl,
SessionImpl, etc. . They have a fixed set of supported return types and perform
the export on a case basis, otherwise they throw an
UnsupportedOperationException.
I don't like having it there, so I'd like to move these implementation outside
and defer them to specific OWL API and Clerezza adapters classes, possibly add
more in the future and keep the core implementation agnostic to exportable
types.
Something like an object able to export to such a class
public interface OWLExporter {
<O> O export(Scope s, Class<O> returnType [, ...]);
<O> O export(OntologySpace s, Class<O> returnType [, ...]);
<O> O export(Session s, Class<O> returnType [, ...]);
boolean canExport(Scope s, Class<O> returnType);
boolean canExport(OntologySpace s, Class<O> returnType);
boolean canExport(Session s, Class<O> returnType);
}
and a general manager where these exporters are registered
public interface ExportManager extends Exporter {
void addExporter(Exporter exporter);
void removeExporter(Exporter exporter);
// ...
}
Or some other way. The important thing is not to have class-specific export()
implementation in the core classes.
Hope this clears it out?
> Use the Sling Adaptable interface to export OWL artifacts
> ---------------------------------------------------------
>
> Key: STANBOL-710
> URL: https://issues.apache.org/jira/browse/STANBOL-710
> Project: Stanbol
> Issue Type: Wish
> Components: Ontology Manager
> Affects Versions: 0.9.0-incubating
> Reporter: Alessandro Adamou
> Priority: Minor
> Labels: adapters, pattern, sling
>
> Sling has a nice interface that can be used for implementing an Adapter
> pattern
> org.apache.sling.api.adapter.Adaptable
> It would be good to use this in lieu of the custom export methods in the
> OWLExportable interface.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira