Java Code Examples for com.bigdata.rdf.model.BigdataStatement#getSubject()

The following examples show how to use com.bigdata.rdf.model.BigdataStatement#getSubject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SparqlGenerator.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see {@link Templates#REMOVE_REIFIED_ELEMENT}
 */
String removeReifiedElement(final BlazeReifiedElement e) {
    final BigdataBNode sid = e.rdfId();
    final BigdataStatement stmt = sid.getStatement();
    final Resource s = stmt.getSubject();
    final URI p = stmt.getPredicate();
    final Value o = stmt.getObject();
    final StringBuilder vc = buildValuesClause(new StringBuilder(), 
            new String[] { "?s", "?p", "?o" }, 
            new Value[]  { s, p, o });
    final String queryStr =
            REMOVE_REIFIED_ELEMENT.replace(Templates.VALUES, vc.toString());
    return queryStr;
}
 
Example 2
Source File: AST2BOpUpdate.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Insert or remove a statement.
     * 
     * @param conn
     *            The connection on which to write the mutation.
     * @param spo
     *            The statement.
     * @param insert
     *            <code>true</code> iff the statement is to be inserted and
     *            <code>false</code> iff the statement is to be removed.
     * @throws SailException
     */
    private static void addOrRemoveStatement(final BigdataSailConnection conn,
            final BigdataStatement spo, final boolean insert) throws SailException {

        final Resource s = (Resource) spo.getSubject();

        final URI p = (URI) spo.getPredicate();
        
        final Value o = (Value) spo.getObject();
        
        /*
         * If [c] is not bound, then using an empty Resource[] for the contexts.
         * 
         * On insert, this will cause the data to be added to the null graph.
         * 
         * On remove, this will cause the statements to be removed from all
         * contexts (on remove it is interpreted as a wildcard).
         */
        
        final Resource c = (Resource) (spo.getContext() == null ? null : spo
                .getContext());
        
        final Resource[] contexts = (Resource[]) (c == null ? NO_CONTEXTS
                : new Resource[] { c });
        
        if(log.isTraceEnabled())
            log.trace((insert ? "INSERT" : "DELETE") + ": <" + s + "," + p
                    + "," + o + "," + Arrays.toString(contexts));
        
        if (insert) {
        
            conn.addStatement(s, p, o, contexts);
            
        } else {

//            /*
//             * We need to handle blank nodes (which can appear in the subject or
//             * object position) as unbound variables.
//             */
//            
//            final Resource s1 = s instanceof BNode ? null : s;
//
//            final Value o1 = o instanceof BNode ? null : o;
//            
//            conn.removeStatements(s1, p, o1, contexts);

            /**
             * 
             * @see <a
             *      href="https://sourceforge.net/apps/trac/bigdata/ticket/571">
             *      DELETE/INSERT WHERE handling of blank nodes </a>
             */
            conn.removeStatements(s, p, o, contexts);

        }

    }
 
Example 3
Source File: AST2BOpUpdate.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Insert or remove a statement (INSERT DATA or DELETE DATA).
     * 
     * @param conn
     *            The connection on which to write the mutation.
     * @param spo
     *            The statement.
     * @param insert
     *            <code>true</code> iff the statement is to be inserted and
     *            <code>false</code> iff the statement is to be removed.
     * @throws SailException
     */
    private static void addOrRemoveStatementData(final BigdataSailConnection conn,
            final BigdataStatement stmt, final boolean insert) throws SailException {

//        final Resource s = (Resource) spo.s().getValue();
//
//        final URI p = (URI) spo.p().getValue();
//        
//        final Value o = (Value) spo.o().getValue();

        final Resource s = stmt.getSubject();
        
        final URI p = stmt.getPredicate();
        
        final Value o = stmt.getObject();
        
        /*
         * If [c] is not bound, then using an empty Resource[] for the contexts.
         * 
         * On insert, this will cause the data to be added to the null graph.
         * 
         * On remove, this will cause the statements to be removed from all
         * contexts (on remove it is interpreted as a wildcard).
         */
        
        final Resource c = (Resource) (stmt.getContext() == null ? null : stmt
                .getContext());

        final Resource[] contexts = (Resource[]) (c == null ? NO_CONTEXTS
                : new Resource[] { c });
        
        if(log.isTraceEnabled())
            log.trace((insert ? "INSERT" : "DELETE") + ": <" + s + "," + p
                    + "," + o + "," + Arrays.toString(contexts));
        
        if (insert) {
        
            conn.addStatement(s, p, o, contexts);
            
        } else {
         
            conn.removeStatements(s, p, o, contexts);
            
        }

    }
 
Example 4
Source File: DescribeCacheUpdater.java    From database with GNU General Public License v2.0 3 votes vote down vote up
/**
 * TODO In order to support CBD, we will also have to recognize
 * statements that describe blank nodes that are part of the description
 * of a described resource as belonging to that described resource. This
 * is necessary in order to capture the transitive closure of the
 * resource description specified by CBD. The code in this method only
 * recognizes statements that directly have a described resource as a
 * subject or object. We probably need a reverse map that will allow us
 * to navigate from a BigdataValue (or perhaps just a BigdataBNode) to
 * all described resources for which that value was observed. That map
 * might only need to contain the blank nodes since the description can
 * never expand beyond a statement having a blank node in the subject
 * (or object) position and a non-blank node in the object (or subject)
 * position.
 * 
 * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/578">
 *      Concise Bounded Description </a>
 */
@Override
public BigdataStatement next() throws QueryEvaluationException {

    // A statement produced by the CONSTRUCT iterator.
    final BigdataStatement stmt = src.next();

    // Check the Subject.
    {
        
        final BigdataValue s = stmt.getSubject();

        // Is the subject one of the described resources?
        if (describedResources.contains(s)) {

            record(s, stmt);

        }
        
    }

    // Check the Object.
    {
        final BigdataValue o = stmt.getObject();

        // Is the object one of the described resources?
        if (describedResources.contains(o)) {

            record(o, stmt);

        }
        
    }
    
    return stmt;

}
 
Example 5
Source File: StatementBuffer.java    From database with GNU General Public License v2.0 3 votes vote down vote up
private void checkSid(final BigdataBNode sid, final URI p, final Value o) {
 	
 	final BigdataStatement stmt = sid.getStatement();
 	
 	if ((p == RDF_SUBJECT && stmt.getSubject() != o) ||
 			(p == RDF_PREDICATE && stmt.getPredicate() != o) ||
 				(p == RDF_OBJECT && stmt.getObject() != o)) {
 		
throw new UnificationException("sid cannot refer to multiple statements");
 		
 	}
 	
 }