Examples of KiWiTriple


Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

                    object = ((LiteralField)rule.getHead().getObject()).getLiteral();
                } else
                    throw new IllegalArgumentException("Object of rule head may only be a variable, a literal, or a resource; rule: "+rule);


                KiWiTriple triple = isail.addInferredStatement(subject, property, object);

                Justification justification = new Justification();
                justification.setTriple(triple);
                justification.getSupportingRules().add(rule);
                justification.getSupportingTriples().addAll(row.getJustifications());
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    protected Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException, ReasoningException {
        Set<Justification> baseJustifications = new HashSet<Justification>();
        Map<KiWiTriple,Collection<Justification>> justificationCache = StatementCommons.newQuadrupleMap();

        for(Justification justification : justifications) {
            KiWiTriple triple = justification.getTriple();

            Justification newJustification = new Justification();
            newJustification.setSupportingRules(justification.getSupportingRules());
            newJustification.setTriple(triple);
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            Set<KiWiTriple> added = new HashSet<KiWiTriple>();
            for(Resource context : contextSet) {
                KiWiResource kcontext = valueFactory.convert(context);

                KiWiTriple triple = (KiWiTriple)valueFactory.createStatement(ksubj,kpred,kobj,kcontext, databaseConnection);
                triple.setInferred(inferred);

                if(triple.getId() == null) {
                    databaseConnection.storeTriple(triple);
                    triplesAdded = true;
                    notifyStatementAdded(triple);
                } else if(deletedStatementsLog.contains(triple.getId())) {
                    // this is a hack for a concurrency problem that may occur in case the triple is removed in the
                    // transaction and then added again; in these cases the createStatement method might return
                    // an expired state of the triple because it uses its own database connection

                    databaseConnection.undeleteTriple(triple);
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    @Override
    protected void removeStatementsInternal(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
        try {
            CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,contexts);
            while(triples.hasNext()) {
                KiWiTriple triple = (KiWiTriple)triples.next();
                if(triple.getId() != null) {
                    databaseConnection.deleteTriple(triple);
                    triplesRemoved = true;
                    deletedStatementsLog.add(triple.getId());
                    notifyStatementRemoved(triple);
                }
            }
            triples.close();
        } catch(SQLException ex) {
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

    @Override
    public boolean removeInferredStatement(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
        try {
            CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,valueFactory.createURI(inferredContext));
            while(triples.hasNext()) {
                KiWiTriple triple = (KiWiTriple)triples.next();
                if(triple.getId() != null && triple.isInferred()) {
                    databaseConnection.deleteTriple(triple);
                    triplesRemoved = true;
                    deletedStatementsLog.add(triple.getId());
                    notifyStatementRemoved(triple);
                }
            }
            triples.close();
        } catch(SQLException ex) {
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

        try {
            List<QueryResult> results = asList(connection.query(Collections.singleton(p), null, null, null, true));
            Assert.assertEquals(1, results.size());
            Assert.assertEquals(1,results.get(0).getJustifications().size());

            KiWiTriple justification = results.get(0).getJustifications().iterator().next();
            Assert.assertEquals(subject, justification.getSubject());
            Assert.assertEquals(predicate, justification.getPredicate());
            Assert.assertEquals(object, justification.getObject());

            connection.commit();
        } finally {
            connection.close();
        }
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            Assert.assertEquals(3, results.size());

            for(int i=0; i<3; i++) {
                Assert.assertEquals(1,results.get(i).getJustifications().size());

                KiWiTriple justification = results.get(i).getJustifications().iterator().next();
                Assert.assertEquals(predicate, justification.getPredicate());
            }

            connection.commit();
        } finally {
            connection.close();
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            Assert.assertEquals(SUBJECT1, results.get(0).getBindings().get(x).stringValue());
            Assert.assertEquals(SUBJECT2, results.get(0).getBindings().get(y).stringValue());
            Assert.assertEquals(OBJECT2, results.get(0).getBindings().get(z).stringValue());

            KiWiTriple justification1 = results.get(0).getJustifications().iterator().next();
            Assert.assertEquals(predicate1, justification1.getPredicate());

            connection.commit();
        } finally {
            connection.close();
        }
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

            // we manually update the "inferred" flag for all inferred triples, since this is not possible through the
            // repository API
            PreparedStatement updateInferred = connection.getJDBCConnection().prepareStatement("UPDATE triples SET inferred = true WHERE id = ?");
            for(Statement stmt : infTriples) {
                KiWiTriple triple = (KiWiTriple)stmt;
                updateInferred.setLong(1,triple.getId());
                updateInferred.addBatch();
            }
            updateInferred.executeBatch();
            updateInferred.close();
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiTriple

     */
    private Date lastModified(RepositoryConnection conn, Resource resource) throws RepositoryException {
        Date last_modified = new Date(0);
        for (Statement triple : listOutgoing(conn, resource)) {
            if(triple instanceof KiWiTriple) {
                KiWiTriple t = (KiWiTriple)triple;
                if (t.getCreated().getTime() > last_modified.getTime()) {
                    last_modified = t.getCreated();
                }
            }
        }
        return last_modified;

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.