Package org.openrdf.repository.sail

Examples of org.openrdf.repository.sail.SailRepositoryConnection


    public void setUp() throws RepositoryException {

        subject = repository.getValueFactory().createURI(ns("foo", UUID.randomUUID().toString()));
        predicate = repository.getValueFactory().createURI(ns("foo", UUID.randomUUID().toString()));

        final SailRepositoryConnection con = repository.getConnection();
        try {
            final ValueFactory vf = con.getValueFactory();

            con.add(vf.createStatement(subject, predicate, vf.createLiteral(text)));

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


    @Test
    public void testStrJoin() throws ParseException, RepositoryException {
        /* unique test, sets up it's own data */
        String[] lits = new String[] {UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString()};
       
        SailRepositoryConnection con = repository.getConnection();
        con.begin();
        con.remove(subject, predicate, null);
        for (int i = 0; i < lits.length; i++) {
            con.add(con.getValueFactory().createStatement(subject, predicate, con.getValueFactory().createLiteral(lits[i])));
        }
        con.commit();
        con.close();
       
        String[] seps = {"###", ", "};
        String[] pres = {"", ":start:"};
        String[] sufs = {"", ":eol:"};
       
View Full Code Here

        iProp = repository.getValueFactory().createURI(NSS.get("foo") + "integer");
        lProp = repository.getValueFactory().createURI(NSS.get("foo") + "long");
        fProp = repository.getValueFactory().createURI(NSS.get("foo") + "float");
        dProp = repository.getValueFactory().createURI(NSS.get("foo") + "double");

        final SailRepositoryConnection con = repository.getConnection();
        try {
            final ValueFactory vF = con.getValueFactory();

            for (int i = 0; i < tSize; i++) {
                con.add(vF.createStatement(subject, iProp, vF.createLiteral(iData[i])));
                con.add(vF.createStatement(subject, lProp, vF.createLiteral(lData[i])));
                con.add(vF.createStatement(subject, fProp, vF.createLiteral(fData[i])));
                con.add(vF.createStatement(subject, dProp, vF.createLiteral(dData[i])));
            }

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

        first = new Date(now.getTime() - 1000l * delta);

        uri = repository.getValueFactory().createURI(NSS.get("ex") + now.getTime());
        prop = repository.getValueFactory().createURI(NSS.get("foo") + "hasPiH"); // Point in History

        final SailRepositoryConnection con = repository.getConnection();

        try {
            final ValueFactory vF = con.getValueFactory();

            con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(first))));
            con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(now))));

            final Random rnd = new Random();
            for (int i = 0; i < 20; i++) {
                Date d = new Date(first.getTime() + rnd.nextInt(delta) * 1000l);
                con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(d))));
            }

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

    private URI prop;

    @Before
    public void setUp() {
        try {
            final SailRepositoryConnection conn = repository.getConnection();
            try {
                conn.begin();
                resource = createURI("foo", "Start");
                prop = createURI("ex", "text");
               
                conn.add(resource, prop, conn.getValueFactory().createLiteral(XML_TEXT));
               
                conn.commit();
            } catch (final Throwable t) {
                conn.rollback();
                fail(t.getMessage());
            } finally {
                conn.close();
            }
        } catch (RepositoryException e) {
            fail("Could not create test-data");
        }
    }
View Full Code Here

        iProp = repository.getValueFactory().createURI(NSS.get("foo") + "integer");
        lProp = repository.getValueFactory().createURI(NSS.get("foo") + "long");
        fProp = repository.getValueFactory().createURI(NSS.get("foo") + "float");
        dProp = repository.getValueFactory().createURI(NSS.get("foo") + "double");

        final SailRepositoryConnection con = repository.getConnection();
        try {
            final ValueFactory vF = con.getValueFactory();

            for (int i = 0; i < tSize; i++) {
                con.add(vF.createStatement(subject, iProp, vF.createLiteral(iData[i])));
                con.add(vF.createStatement(subject, lProp, vF.createLiteral(lData[i])));
                con.add(vF.createStatement(subject, fProp, vF.createLiteral(fData[i])));
                con.add(vF.createStatement(subject, dProp, vF.createLiteral(dData[i])));
            }

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

        first = new Date(now.getTime() - 1000l * delta);

        uri = repository.getValueFactory().createURI(NSS.get("ex") + now.getTime());
        prop = repository.getValueFactory().createURI(NSS.get("foo") + "hasPiH"); // Point in History

        final SailRepositoryConnection con = repository.getConnection();

        try {
            final ValueFactory vF = con.getValueFactory();

            con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(first))));
            con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(now))));

            final Random rnd = new Random();
            for (int i = 0; i < 20; i++) {
                Date d = new Date(first.getTime() + rnd.nextInt(delta) * 1000l);
                con.add(vF.createStatement(uri, prop, vF.createLiteral(DateUtils.getXMLCalendar(d))));
            }

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

    protected final void loadData(String datafile, RDFFormat format, String baseURI) throws RepositoryException, RDFParseException, IOException {
        // load demo data
        InputStream data = this.getClass().getResourceAsStream(datafile);
        Assume.assumeThat("Could not load test-data: " + datafile, data, notNullValue(InputStream.class));

        final SailRepositoryConnection con = repository.getConnection();
        try {

            con.add(data, baseURI, format);

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

TOP

Related Classes of org.openrdf.repository.sail.SailRepositoryConnection

Copyright © 2018 www.massapicom. 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.