use of org.apache.jena.sdb.StoreDesc in project jena by apache.
the class SDBModelAssembler method open.
@Override
public Model open(Assembler a, Resource root, Mode mode) {
// Make a model.
// [] rdf:type sdb:Model ;
// sdb:dataset <dataset> ;
// sdb:graphName <someURI> .
// A model (graph) is a (dataset, name) pair where the name can be absent
// meaning the default graph of the dataset.
Resource dataset = GraphUtils.getResourceValue(root, AssemblerVocab.pDataset);
if (dataset == null)
throw new MissingException(root, "No dataset for model or graph");
StoreDesc storeDesc = datasetAssem.openStore(a, dataset, mode);
// Attempt to find a graph name - may be absent.
// Two names : "namedGraph" and "graphName"
String x = GraphUtils.getAsStringValue(root, AssemblerVocab.pNamedGraph1);
if (x == null)
x = GraphUtils.getAsStringValue(root, AssemblerVocab.pNamedGraph2);
// No name - default model.
Graph g = null;
if (x == null)
return SDBFactory.connectDefaultModel(storeDesc);
else
return SDBFactory.connectNamedModel(storeDesc, x);
}
use of org.apache.jena.sdb.StoreDesc in project jena by apache.
the class StoreDescAssembler method open.
@Override
public StoreDesc open(Assembler a, Resource root, Mode mode) {
SDBConnectionDesc sdbConnDesc = null;
Resource c = GraphUtils.getResourceValue(root, AssemblerVocab.pConnection);
if (c != null)
sdbConnDesc = (SDBConnectionDesc) a.open(c);
String layoutName = GraphUtils.getStringValue(root, AssemblerVocab.pLayout);
String dbType = chooseDBType(root, sdbConnDesc);
// Features
List<Resource> x = GraphUtils.multiValueResource(root, AssemblerVocab.featureProperty);
FeatureSet fSet = new FeatureSet();
for (Resource r : x) {
String n = GraphUtils.getStringValue(r, AssemblerVocab.featureNameProperty);
String v = GraphUtils.getStringValue(r, AssemblerVocab.featureValueProperty);
Feature f = new Feature(new Feature.Name(n), v);
fSet.addFeature(f);
}
StoreDesc storeDesc = new StoreDesc(layoutName, dbType, fSet);
storeDesc.connDesc = sdbConnDesc;
// MySQL specials
String engineName = GraphUtils.getStringValue(root, AssemblerVocab.pMySQLEngine);
storeDesc.engineType = null;
if (engineName != null)
try {
storeDesc.engineType = MySQLEngineType.convert(engineName);
} catch (SDBException ex) {
}
// SAP specials
String storageType = GraphUtils.getStringValue(root, AssemblerVocab.pStorageType);
if (storageType != null)
try {
storeDesc.storageType = SAPStorageType.convert(storageType);
} catch (SDBException ex) {
}
return storeDesc;
}
use of org.apache.jena.sdb.StoreDesc in project jena by apache.
the class Ex2 method main.
public static void main(String... argv) {
String queryString = "SELECT * { ?s ?p ?o }";
Query query = QueryFactory.create(queryString);
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.Derby);
// Multiple choices for Derby - load the embedded driver
JDBC.loadDriverDerby();
String jdbcURL = "jdbc:derby:DB/SDB2";
// Passing null for user and password causes them to be extracted
// from the environment variables SDB_USER and SDB_PASSWORD
SDBConnection conn = new SDBConnection(jdbcURL, null, null);
// Make store from connection and store description.
Store store = SDBFactory.connectStore(conn, storeDesc);
Dataset ds = DatasetStore.create(store);
QueryExecution qe = QueryExecutionFactory.create(query, ds);
try {
ResultSet rs = qe.execSelect();
ResultSetFormatter.out(rs);
} finally {
qe.close();
}
store.close();
}
use of org.apache.jena.sdb.StoreDesc in project jena by apache.
the class sdbprint method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
// Force the connection to be a null one.
// Known to be called after arg module initialization.
StoreDesc storeDesc = getModStore().getStoreDesc();
storeDesc.connDesc.setJdbcURL(JDBC.jdbcNone);
if (storeDesc.getLayout() == null)
storeDesc.setLayout(layoutDefault);
printSQL = contains(argDeclPrintSQL);
List<String> strList = getValues(argDeclPrint);
for (String arg : strList) {
if (arg.equalsIgnoreCase("query")) {
printQuery = true;
} else if (arg.equalsIgnoreCase("Op")) {
printOp = true;
} else if (arg.equalsIgnoreCase("SqlNode")) {
printSqlNode = true;
} else if (arg.equalsIgnoreCase("sql")) {
printSQL = true;
} else if (arg.equalsIgnoreCase("plan")) {
printPlan = true;
} else
throw new CmdException("Not a recognized print form: " + arg + " : Choices are: query, prefix, op, sqlNode, sql");
}
}
use of org.apache.jena.sdb.StoreDesc in project jena by apache.
the class QueryTestSDBFactory method make.
public static void make(TestSuite ts, String storeList, String manifestFile) {
for (Pair<String, StoreDesc> p : StoreList.stores(storeList)) {
String label = p.car();
StoreDesc storeDesc = p.cdr();
if (label != null && !label.equals(""))
label = label + " - ";
TestSuite ts2 = make(storeDesc, manifestFile, label);
ts.addTest(ts2);
}
}
Aggregations