Package com.clarkparsia.empire.ds

Examples of com.clarkparsia.empire.ds.DataSourceException


    try {
      mConnection.rollback();
    }
    catch (RepositoryException e) {
      throw new DataSourceException(e);
    }
  }
View Full Code Here


        throws DataSourceException {
      try {
      return AdunaIterations.iterable(mConnection.getStatements(theSubject, thePredicate, theObject, true));
    }
    catch (RepositoryException e) {
      throw new DataSourceException(e);
    }
    }
View Full Code Here

     
      try {
      return AdunaIterations.iterable(mConnection.getStatements(theSubject, thePredicate, theObject, true, theContext));
    }
    catch (RepositoryException e) {
      throw new DataSourceException(e);
    }
    }
View Full Code Here

   * @inheritDoc
   */
    @Override
  public DataSource create(final Map<String, Object> theMap) throws DataSourceException {
    if (!canCreate(theMap)) {
      throw new DataSourceException("Invalid configuration map: " + theMap);
    }

        Object aName = theMap.get(ConfigKeys.NAME);
    Object aURL = theMap.get(URL);
    Object aRepo = theMap.get(REPO);
    Object aFiles = theMap.get(FILES);
    Object aDir = theMap.get(DIR);
    Object aPhysRepo = theMap.get(REPO_HANDLE);

    Repository aRepository;

    try {
      if (aPhysRepo != null) {
        aRepository = (Repository) aPhysRepo;
      }
      else if (aURL != null && aRepo != null) {
        aRepository = new HTTPRepository(aURL.toString(), aRepo.toString());

        aRepository.initialize();
      }
      else if (aFiles != null) {
        aRepository = new SailRepository(new MemoryStore());

        try {
          aRepository.initialize();
       
          RepositoryConnection aConn = null;

                    try {
                        aConn = aRepository.getConnection();
                        aConn.begin();

                        for (String aFile : Splitter.on(',').omitEmptyStrings().trimResults().split(aFiles.toString())) {
                            RDFParser aParser = Rio.createParser(Rio.getParserFormatForFileName(aFile));

                            aParser.setRDFHandler(new RDFInserter(aConn));

                            if (NetUtils.isURL(aFile)) {
                                aParser.parse(new java.net.URL(aFile).openStream(), "");
                            }
                            else {
                                aParser.parse(new FileInputStream(aFile), "");
                            }
                        }

                        aConn.commit();
                    }
                    finally {
                        if (aConn != null) {
                            aConn.close();
                        }
                    }
                }
        catch (Exception e) {
          throw new DataSourceException(e);
        }
      }
      else if (aDir != null) {
        aRepository = new SailRepository(new MemoryStore(new File(aDir.toString())));

        aRepository.initialize();
      }
      else {
        aRepository = new SailRepository(new MemoryStore());
        aRepository.initialize();
      }

      return new RepositoryDataSource(aRepository, theMap.containsKey(QUERY_LANG) && theMap.get(QUERY_LANG).toString().equalsIgnoreCase(LANG_SERQL));
    }
    catch (RepositoryException e) {
      throw new DataSourceException(e);
    }
  }
View Full Code Here

          mDataSource.add(op.getData());
        }
      }
    }
    catch (DataSourceException e) {
      throw new DataSourceException("Rollback failed, database is likely to be in an inconsistent state.", e);
    }
    finally {
      mIsInTransaction = false;

      mTransactionOps.clear();
View Full Code Here

   * Asserts that this DataSource should not be in a transaction
   * @throws com.clarkparsia.empire.ds.DataSourceException thrown if the data source is in a transaction
   */
  private void assertNotInTransaction() throws DataSourceException {
    if (isInTransaction()) {
      throw new DataSourceException("Cannot complete action, currently in a transaction");
    }
  }
View Full Code Here

   * Asserts that this DataSource should be in a transaction
   * @throws DataSourceException thrown if the data source is not in a transaction
   */
  private void assertInTransaction() throws DataSourceException {
    if (!isInTransaction()) {
      throw new DataSourceException("Cannot complete action, not in a transaction");
    }
  }
View Full Code Here

        }

        return new SparqlEndpointDataSource(new URL(theMap.get(KEY_URL).toString()), aDialect);
      }
      catch (MalformedURLException e) {
        throw new DataSourceException(e);
      }
    }
    else {
      throw new DataSourceException("Invalid configuration map, missing required key '" + KEY_URL + "'.");
    }
  }
View Full Code Here

  public void add(final Graph theGraph) throws DataSourceException {
    try {
      Repositories.add(getRepository(), theGraph);
    }
    catch (Exception e) {
      throw new DataSourceException(e);
    }
  }
View Full Code Here

  public void remove(final Graph theGraph) throws DataSourceException {
    try {
      Repositories.remove(getRepository(), theGraph);
    }
    catch (Exception e) {
      throw new DataSourceException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.clarkparsia.empire.ds.DataSourceException

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.