Skip to content

Instantly share code, notes, and snippets.

@egonw
Created July 20, 2009 11:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save egonw/150268 to your computer and use it in GitHub Desktop.
var metwareModel = pellet.createStore();
js.clear();
rdf.importFile(metwareModel, "/OWL/MetWare/metware.skos", "RDF/XML");
// loop over collections (aka SQL schema)
var collections = pellet.reason(metwareModel,
"PREFIX mw: <http://metware.sf.net/onto/#> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"SELECT ?id WHERE { " +
" ?id rdf:type mw:MetwareCollection. " +
"}"
);
for (var collectionIndex=0; collectionIndex<collections.size(); collectionIndex++) {
var collection = collections.get(collectionIndex);
var collectionID = collection.get(0);
js.print("SQL schema: " + collectionID + "\n");
// loop over all tables in the collection (aka SQL tables)
var tables = pellet.reason(metwareModel,
"PREFIX mw: <http://metware.sf.net/onto/#> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
"SELECT ?id WHERE { " +
" " + collectionID + " skos:member ?id. " +
"}"
);
for (var tableIndex=0; tableIndex<tables.size(); tableIndex++) {
var table = tables.get(tableIndex);
var tableID = table.get(0);
js.print(" table: " + tableID + "\n");
// loop over all fields of the table
var fields = pellet.reason(metwareModel,
"PREFIX mw: <http://metware.sf.net/onto/#> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
"SELECT ?id WHERE { " +
" ?id skos:broader " + tableID + ". " +
"}"
);
for (var fieldIndex=0; fieldIndex<fields.size(); fieldIndex++) {
var field = fields.get(fieldIndex);
var fieldID = field.get(0);
js.print(" field: " + fieldID + "\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment