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

The following examples show how to use com.bigdata.rdf.model.BigdataStatement#getPredicate() . 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: BlazeGraph.java    From tinkerpop3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Binding set to vertex property (for Vertex elements).
 */
private final <V> Function<BindingSet, VertexProperty<V>> 
vertexProperty(final BlazeVertex v) {
    return bs -> {

        log.debug(() -> bs);
        final Literal val = (Literal) bs.getValue("val");
        final BigdataBNode sid = (BigdataBNode) bs.getValue("vp");
        final BigdataStatement stmt = sid.getStatement();
        final URI key = stmt.getPredicate();
        final String vpId = vertexPropertyId(stmt);
        final BlazeProperty<V> prop = 
                new BlazeProperty<>(BlazeGraph.this, v, key, val);
        final BlazeVertexProperty<V> bvp = 
                new BlazeVertexProperty<>(prop, vpId, sid);
        return bvp;

    };
}
 
Example 2
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 3
Source File: BlazeEdge.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an instance.
 */
BlazeEdge(final BlazeGraph graph, final BigdataStatement stmt, 
        final BigdataURI label, final BlazeVertex from, final BlazeVertex to) {
    super(graph, stmt.getPredicate(), label);
    final BigdataValueFactory rdfvf = graph.rdfValueFactory();
    this.sid = rdfvf.createBNode(stmt);
    this.vertices = new Vertices(from, to);
}
 
Example 4
Source File: BlazeEdge.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an instance without vertices.  Used by 
 * {@link BlazeGraph#bulkLoad(Graph)}
 */
BlazeEdge(final BlazeGraph graph, final BigdataStatement stmt, 
        final BigdataURI label) {
    super(graph, stmt.getPredicate(), label);
    final BigdataValueFactory rdfvf = graph.rdfValueFactory();
    this.sid = rdfvf.createBNode(stmt);
    this.vertices = null;
}
 
Example 5
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 6
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 7
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");
 		
 	}
 	
 }