001: /*
002: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: package jena;
007:
008: import jena.util.DBcmd;
009:
010: import com.hp.hpl.jena.db.*;
011: import com.hp.hpl.jena.rdf.model.*;
012: import com.hp.hpl.jena.util.iterator.*;
013:
014: /** List the models available in a database
015: * <p>
016: * Usage:<pre>
017: * jena.dblist [db spec]
018: * where [db spec] is:
019: * --spec file Contains an RDF description of the model
020: * --db JDBC_url --dbUser userId --dbPassword password --dbType
021: * </pre>
022: * Ignores any <code>--model modelName</code>.
023: * </p>
024: *
025: * @author Andy Seaborne
026: * @version $Id: dblist.java,v 1.10 2008/01/02 12:08:16 andy_seaborne Exp $
027: */
028:
029: public class dblist extends DBcmd {
030: public static final String[] usage = new String[] {
031: "dblist [--spec spec] | [db_description] [--model name]",
032: " where db_description is",
033: " --db JDBC URL --dbType type",
034: " --dbUser user --dbPassword password" };
035:
036: public static void main(String[] args) {
037: dblist db = new dblist();
038: db.setUsage(usage);
039: db.init(args);
040: db.exec();
041: }
042:
043: public dblist() {
044: super ("dblist", false);
045: }
046:
047: static String defaultModelName = "DEFAULT";
048:
049: protected void exec0() {
050: // if ( getConnection().containsDefaultModel() )
051: // {
052: // System.out.println("Model: <<default model>>") ;
053: // properties(null) ;
054: // }
055:
056: ClosableIterator iter = getConnection().getAllModelNames();
057: try {
058: for (; iter.hasNext();) {
059: String name = (String) iter.next();
060: System.out.println("Model: " + name);
061: properties(name);
062: }
063: } finally {
064: iter.close();
065: }
066:
067: }
068:
069: protected boolean exec1(String arg) {
070: return true;
071: }
072:
073: private void properties(String name) {
074: if (true)
075: return;
076: ModelRDB m = ModelRDB.open(getConnection(), name);
077: Model props = m.getModelProperties();
078: props.setNsPrefix("db", "http://jena.hpl.hp.com/2003/04/DB#");
079: props.write(System.out, "N3");
080: props.close();
081: }
082:
083: }
084:
085: /*
086: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
087: * All rights reserved.
088: *
089: * Redistribution and use in source and binary forms, with or without
090: * modification, are permitted provided that the following conditions
091: * are met:
092: * 1. Redistributions of source code must retain the above copyright
093: * notice, this list of conditions and the following disclaimer.
094: * 2. Redistributions in binary form must reproduce the above copyright
095: * notice, this list of conditions and the following disclaimer in the
096: * documentation and/or other materials provided with the distribution.
097: * 3. The name of the author may not be used to endorse or promote products
098: * derived from this software without specific prior written permission.
099: *
100: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
101: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
102: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
103: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
104: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
105: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
106: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
107: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
109: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
110: */
|