Package com.complexible.stardog.api

Examples of com.complexible.stardog.api.Connection


   * @param mapper implementation of RowMapper
   * @param <T> generic type of RowMapper
   * @return single result of the RowMapper call
   */
  public <T> T queryForObject(String sparql, Map<String, Object> args, RowMapper<T> mapper) {
    Connection connection = dataSource.getConnection();
    TupleQueryResult result = null;
    try {
      SelectQuery query = connection.select(sparql);
     
      if (args != null) {
        for (Entry<String, Object> arg : args.entrySet()) {    
          query.parameter(arg.getKey(), arg.getValue());
        }
View Full Code Here


   * @param sparql the SPARQL ask query to execute
   * @param args map of string and object to pass bind as input parameters
   * @return boolean if the query matches in the database
   */
  public boolean ask(String sparql, Map<String, Object> args) {
    Connection connection = dataSource.getConnection();
    Boolean result = null;
    try {
      BooleanQuery query = connection.ask(sparql);
     
      if (args != null) {
        for (Entry<String, Object> arg : args.entrySet()) {          
          query.parameter(arg.getKey(), arg.getValue());
        }
View Full Code Here

   * @param sparql the SPARQL update to execute
   * @param args map of string and object to pass bind as input parameters
   *
   */
  public void update(String sparql, Map<String, Object> args) {
    Connection connection = dataSource.getConnection();
    try {
      UpdateQuery query = connection.update(sparql);
     
      if (args != null) {
        for (Entry<String, Object> arg : args.entrySet()) {          
          query.parameter(arg.getKey(), arg.getValue());
        }
View Full Code Here

   * @param graph Graph to use for the adder
   * @param graphUri graph URi to use
   */
  public void add(Graph graph, String graphUri) {
    Resource context = (graphUri == null ? null : ValueFactoryImpl.getInstance().createURI(graphUri));
    Connection connection = dataSource.getConnection();
    try {
      connection.begin();
      if (context != null) {
        connection.add().graph(graph, context);
      } else {
        connection.add().graph(graph);
      }
      connection.commit();
    } catch (StardogException e) {
      log.error("Error adding graph to Stardog", e);
      throw new RuntimeException(e);
    } finally {
      context = null;
View Full Code Here

 
  private BatchAdderCallback<T> callback;
 
  @Override
  public void write(List<? extends T> items) throws Exception {
    Connection connection = dataSource.getConnection();
    Adder adder = null;
    try {
      connection.begin();
      adder = connection.add();
      callback.write(adder, items);
      connection.commit();
    } catch (StardogException e) {
      log.error("Error with SnarlItemWriter ", e);
      throw new RuntimeException(e);
    } finally {
      adder = null;
View Full Code Here

TOP

Related Classes of com.complexible.stardog.api.Connection

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.