Package org.openrdf.repository

Examples of org.openrdf.repository.RepositoryConnection.begin()


            // remove a resource and all its triples
            connection.begin();
            ResourceUtils.removeResource(connection, connection.getValueFactory().createURI("http://localhost:8080/LMF/resource/hans_meier"));
            connection.commit();

            connection.begin();
            long newsize = connection.size();

            // new size should be less, since we removed some triples
            Assert.assertThat(newsize, lessThan(oldsize));
View Full Code Here


        long oldsize, newsize;
        List<Statement> oldTriples, newTriples;

        RepositoryConnection connectionRDF = repository.getConnection();
        try {
            connectionRDF.begin();
            connectionRDF.add(rdfXML, "http://localhost/srfg/", RDFFormat.RDFXML);
            connectionRDF.commit();

            oldTriples = Iterations.asList(connectionRDF.getStatements(null,null,null,true));
            oldsize = connectionRDF.size();
View Full Code Here

        // get another connection and add the same data again
        rdfXML = this.getClass().getResourceAsStream("srfg-ontology.rdf");
        RepositoryConnection connection = repository.getConnection();

        try {
            connection.begin();
            connection.add(rdfXML, "http://localhost/srfg/", RDFFormat.RDFXML);
            connection.commit();

            newTriples = Iterations.asList(connection.getStatements(null,null,null,true));
            newsize = connection.size();
View Full Code Here

    public static Repository loadData(String path, RDFFormat format) throws RDFParseException, RepositoryException, IOException {
        Repository repo = new SailRepository(new MemoryStore());
        repo.initialize();
        RepositoryConnection conn = repo.getConnection();
        try {
            conn.begin();
            conn.clear();
            InputStream is = LdpTestCasesUtils.class.getResourceAsStream(path);
            if (is == null) {
                throw new IOException("Manifest file not found at: " + path);
            } else {
View Full Code Here

            URI context = null;
            if(context_string != null) {
                try {
                    RepositoryConnection conn = sesameService.getConnection();
                    try {
                        conn.begin();
                        context = ResourceUtils.getUriResource(conn,context_string);
                    } finally {
                        conn.commit();
                        conn.close();
                    }
View Full Code Here

        List<URI> containers = new ArrayList<URI>();
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                checkConnectionNamespace(conn);
                conn.begin();
                Iterable<Resource> results = ResourceUtils.listResources(conn, conn.getValueFactory().createURI(prefixService.getNamespace("ldp"), "Container"));
                for (Resource result : results) {
                    if(result instanceof URI) {
                        containers.add((URI)result);
                   
View Full Code Here

    public URI get(String uri) {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                checkConnectionNamespace(conn);
                conn.begin();
                return (ResourceUtils.existsResource(conn, uri) ? ResourceUtils.getUriResource(conn, uri) : null);
            } finally {
                conn.commit();
                conn.close();
            }
View Full Code Here

        //by moving all business logic to a service
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                checkConnectionNamespace(conn);
                conn.begin();
                ValueFactory factory = conn.getValueFactory();
                URI resource = ResourceUtils.getUriResource(conn, uri);
                //TODO: chek if already exists
                conn.add(resource, RDF.TYPE, factory.createURI(prefixService.getNamespace("ldp"), "Resource"), container);
                conn.add(resource, factory.createURI(prefixService.getNamespace("dct"), "created"), factory.createLiteral(new Date()), container);
View Full Code Here

    private boolean createContainer(String container, String title) throws URISyntaxException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                checkConnectionNamespace(conn);
                conn.begin();
                ValueFactory factory = conn.getValueFactory();
                URI uri = ResourceUtils.getUriResource(conn, container);
                conn.add(uri, RDF.TYPE, factory.createURI(prefixService.getNamespace("ldp"), "Container"), context);
                conn.add(uri, RDFS.LABEL, factory.createLiteral(title), context);
                conn.add(uri, factory.createURI(prefixService.getNamespace("dct"), "created"), factory.createLiteral(new Date()), context);
View Full Code Here

            parent = getParentContainer(uri);
        } catch (URISyntaxException e) {
            parent = null;
        }
        try {
            conn.begin();
            URI resource = conn.getValueFactory().createURI(uri);
            conn.remove(resource, null, null, parent);
            return true;
        } finally {
            conn.commit();
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.