This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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