use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractJenaConnectionTests method connection_statement_query_describe_02.
/**
* Runs a CONSTRUCT query on a non-empty database and checks it returns
* non-empty results
*
* @throws SQLException
*/
@Test
public void connection_statement_query_describe_02() throws SQLException {
// Prepare a dataset
Dataset ds = DatasetFactory.createTxnMem();
ds.asDatasetGraph().add(new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"), NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
// Work with the connection
JenaConnection conn = this.getConnection(ds);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("DESCRIBE ?s WHERE { GRAPH ?g { ?s ?p ?o } }");
Assert.assertNotNull(rset);
Assert.assertFalse(rset.isClosed());
Assert.assertTrue(rset.isBeforeFirst());
// Should have a row
Assert.assertTrue(rset.next());
Assert.assertTrue(rset.isFirst());
Assert.assertEquals(1, rset.getRow());
// Should be no further rows
Assert.assertFalse(rset.next());
Assert.assertTrue(rset.isAfterLast());
Assert.assertFalse(rset.isClosed());
// Close things
rset.close();
Assert.assertTrue(rset.isClosed());
stmt.close();
Assert.assertTrue(stmt.isClosed());
conn.close();
Assert.assertTrue(conn.isClosed());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractJenaConnectionTests method connection_statement_query_select_03.
/**
* Runs a SELECT query on a non-empty database and checks it returns
* non-empty results
*
* @throws SQLException
*/
@Test
public void connection_statement_query_select_03() throws SQLException {
// Prepare a dataset
Dataset ds = DatasetFactory.createTxnMem();
ds.asDatasetGraph().add(new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"), NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
// Work with the connection
JenaConnection conn = this.getConnection(ds);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }");
Assert.assertNotNull(rset);
Assert.assertFalse(rset.isClosed());
Assert.assertTrue(rset.isBeforeFirst());
// Check result set metadata
checkSelectMetadata(rset, 1);
// Should have a row
Assert.assertTrue(rset.next());
Assert.assertTrue(rset.isFirst());
Assert.assertEquals(1, rset.getRow());
// Should be no further rows
Assert.assertFalse(rset.next());
Assert.assertTrue(rset.isAfterLast());
Assert.assertFalse(rset.isClosed());
// Close things
rset.close();
Assert.assertTrue(rset.isClosed());
stmt.close();
Assert.assertTrue(stmt.isClosed());
conn.close();
Assert.assertTrue(conn.isClosed());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractJenaConnectionTests method connection_statement_query_construct_02.
/**
* Runs a CONSTRUCT query on a non-empty database and checks it returns
* non-empty results
*
* @throws SQLException
*/
@Test
public void connection_statement_query_construct_02() throws SQLException {
// Prepare a dataset
Dataset ds = DatasetFactory.createTxnMem();
ds.asDatasetGraph().add(new Quad(NodeFactory.createURI("http://example/graph"), NodeFactory.createURI("http://example/subject"), NodeFactory.createURI("http://example/predicate"), NodeFactory.createURI("http://example/object")));
// Work with the connection
JenaConnection conn = this.getConnection(ds);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o } }");
Assert.assertNotNull(rset);
Assert.assertFalse(rset.isClosed());
Assert.assertTrue(rset.isBeforeFirst());
// Should have a row
Assert.assertTrue(rset.next());
Assert.assertTrue(rset.isFirst());
Assert.assertEquals(1, rset.getRow());
// Should be no further rows
Assert.assertFalse(rset.next());
Assert.assertTrue(rset.isAfterLast());
Assert.assertFalse(rset.isClosed());
// Close things
rset.close();
Assert.assertTrue(rset.isClosed());
stmt.close();
Assert.assertTrue(stmt.isClosed());
conn.close();
Assert.assertTrue(conn.isClosed());
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class SlotCompilerIndex method classify.
protected void classify(QuadBlock quadBlock, Collection<Node> constants, Collection<Var> vars) {
for (Quad quad : quadBlock) {
// Some constants are only markers and are not stored in the database.
if (// quad.isDefaultGraph ARQ 2.8.4 and later
!Quad.isDefaultGraph(quad.getGraph()) && !quad.isUnionGraph())
acc(constants, vars, quad.getGraph());
acc(constants, vars, quad.getSubject());
acc(constants, vars, quad.getPredicate());
acc(constants, vars, quad.getObject());
}
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class T_QuadsObjectIsNull method one.
public static void one() {
Quad q1 = SSE.parseQuad("(<g1> <s1> <p1> '1')");
Quad q2 = SSE.parseQuad("(<g2> <s2> <p2> '2')");
Quad q3 = SSE.parseQuad("(<g3> <s3> <p3> '3')");
DatasetGraphTransaction dsg = (DatasetGraphTransaction) TDBFactory.createDatasetGraph(location);
System.out.println("Start");
dump(dsg);
write(dsg, q1);
write(dsg, q2);
//write(dsg, q3) ;
System.out.println("Finish");
dump(dsg);
}
Aggregations