Search in sources :

Example 6 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class SesameGraph method dump.

public void dump(Writer writer) {
    try {
        if (contextResource.length == 0) {
            RepositoryResult<org.openrdf.model.Resource> results = conn.getContextIDs();
            while (results.hasNext()) {
                org.openrdf.model.Resource context = results.next();
                writer.append("Dumping context:" + context + "\n");
                conn.export(new RDFXMLWriter(writer), context);
            }
            dumpTriplesNotInContext(writer);
        } else {
            for (int i = 0; i < contextResource.length; i++) {
                writer.append("Dumping context:" + contextResource[i].stringValue() + "\n");
                conn.export(new RDFXMLWriter(writer), contextResource);
            }
        }
    } catch (Exception e) {
        throw new ShineRuntimeException(e);
    }
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RDFXMLWriter(org.openrdf.rio.rdfxml.RDFXMLWriter) Resource(com.thoughtworks.studios.shine.semweb.Resource) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) TupleQueryResultHandlerException(org.openrdf.query.TupleQueryResultHandlerException) MoreThanOneResultFoundException(com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException) MalformedSPARQLException(com.thoughtworks.studios.shine.semweb.MalformedSPARQLException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) OpenRDFException(org.openrdf.OpenRDFException) NoSuchElementException(java.util.NoSuchElementException) MalformedQueryException(org.openrdf.query.MalformedQueryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)

Example 7 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class SesameGraph method selectFirst.

public BoundVariables selectFirst(String sparqlSelect) {
    BoundVariables boundVariables;
    TupleQueryResult tupleQueryResult = getTupleQueryResult(sparqlSelect);
    try {
        if (!tupleQueryResult.hasNext()) {
            return null;
        }
        boundVariables = new SesameBoundVariables(tupleQueryResult.getBindingNames(), tupleQueryResult.next());
        if (tupleQueryResult.hasNext()) {
            tupleQueryResult.close();
            throw new MoreThanOneResultFoundException(sparqlSelect);
        }
    } catch (QueryEvaluationException e) {
        throw new ShineRuntimeException("Could not parse query: <<" + sparqlSelect + ">>", e);
    }
    return boundVariables;
}
Also used : BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) MoreThanOneResultFoundException(com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException) TupleQueryResult(org.openrdf.query.TupleQueryResult)

Example 8 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class SesameGraph method createURIReference.

public URIReference createURIReference(RDFType type, String uri) {
    ArgumentUtil.guaranteeNotNull(type, "Type may not be null.");
    ArgumentUtil.guaranteeNotNull(uri, "URI may not be null.");
    ArgumentUtil.guaranteeFalse("URI may not be a blank node!", uri.startsWith("_:"));
    URI sesameNativeURI = conn.getValueFactory().createURI(uri);
    try {
        conn.add(sesameNativeURI, RDF.TYPE, conn.getValueFactory().createURI(type.getURIText()), contextResource);
    } catch (RepositoryException e) {
        throw new ShineRuntimeException(e);
    }
    return new SesameURIReference(sesameNativeURI);
}
Also used : ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) URI(org.openrdf.model.URI)

Example 9 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class NUnitRDFizer method importFile.

public Graph importFile(final String parentURI, Document document) throws GrddlTransformException {
    final DocumentResult result = new DocumentResult();
    final DocumentSource source = new DocumentSource(document);
    try {
        return xsltTransformerRegistry.transformWithCorrectClassLoader(XSLTTransformerRegistry.XUNIT_NUNIT_TO_JUNIT_XSL, new XSLTTransformerExecutor<Graph>() {

            @Override
            public Graph execute(Transformer transformer) throws TransformerException, GrddlTransformException {
                transformer.transform(source, result);
                return jUnitRDFizer.importFile(parentURI, result.getDocument());
            }
        });
    } catch (TransformerException e) {
        throw new ShineRuntimeException(e);
    }
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) Transformer(javax.xml.transform.Transformer) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) DocumentResult(org.dom4j.io.DocumentResult) DocumentSource(org.dom4j.io.DocumentSource) GrddlTransformException(com.thoughtworks.studios.shine.semweb.grddl.GrddlTransformException) TransformerException(javax.xml.transform.TransformerException)

Example 10 with ShineRuntimeException

use of com.thoughtworks.studios.shine.ShineRuntimeException in project gocd by gocd.

the class InMemoryRepositoryFactory method emptyRepository.

public static Repository emptyRepository() {
    try {
        Repository repo = new SailRepository(new MemoryStore());
        repo.initialize();
        return repo;
    } catch (RepositoryException ex) {
        throw new ShineRuntimeException(ex);
    }
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailRepository(org.openrdf.repository.sail.SailRepository) RepositoryException(org.openrdf.repository.RepositoryException)

Aggregations

ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)23 RepositoryException (org.openrdf.repository.RepositoryException)16 URI (org.openrdf.model.URI)8 IOException (java.io.IOException)7 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)7 MoreThanOneResultFoundException (com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException)6 Graph (com.thoughtworks.studios.shine.semweb.Graph)5 MalformedSPARQLException (com.thoughtworks.studios.shine.semweb.MalformedSPARQLException)5 UnsupportedSPARQLStatementException (com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)5 NoSuchElementException (java.util.NoSuchElementException)5 OpenRDFException (org.openrdf.OpenRDFException)5 MalformedQueryException (org.openrdf.query.MalformedQueryException)5 TupleQueryResultHandlerException (org.openrdf.query.TupleQueryResultHandlerException)5 RDFHandlerException (org.openrdf.rio.RDFHandlerException)5 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)3 BooleanQuery (org.openrdf.query.BooleanQuery)3 TupleQuery (org.openrdf.query.TupleQuery)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)2 Transformer (javax.xml.transform.Transformer)2 TransformerException (javax.xml.transform.TransformerException)2