Java Code Examples for org.openrdf.repository.RepositoryException#printStackTrace()

The following examples show how to use org.openrdf.repository.RepositoryException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpecificResourceSupport.java    From anno4j with Apache License 2.0 6 votes vote down vote up
@Override
public void delete() {
    try {
        ObjectConnection connection = getObjectConnection();

        // deleting an existing selector
        if(getSelector() != null) {
            getSelector().delete();
            setSelector(null);
        }

        connection.removeDesignation(this, (URI) getResource());
        // explicitly removing the rdf type triple from the repository
        connection.remove(getResource(), null, null);
        connection.remove(null, null, getResource(), null);
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: CustomSesameDataset.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * Load data in specified graph (use default graph if contexts is null)
 * 
 * @param filePath
 * @param format
 * @param contexts
 * @throws RepositoryException
 * @throws IOException
 * @throws RDFParseException
 */
public void loadDataFromFile(String filePath, RDFFormat format,
		Resource... contexts) throws RepositoryException,
		RDFParseException, IOException {
	RepositoryConnection con = null;
	try {
		con = currentRepository.getConnection();
		// upload a file
		File f = new File(filePath);
		con.add(f, null, format, contexts);
	} finally {
		try {
			con.close();
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}

}
 
Example 3
Source File: CustomSesameDataset.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
public void loadDataFromInputStream(InputStream is, RDFFormat format,
		Resource... contexts) throws RepositoryException,
		RDFParseException, IOException {
	RepositoryConnection con = null;
	try {
		con = currentRepository.getConnection();
		con.add(is, "http://geotriples.eu", format, contexts);
	} finally {
		try {
			con.close();
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}

}
 
Example 4
Source File: SesameRepositoryImpl.java    From sparql-playground with GNU General Public License v2.0 5 votes vote down vote up
public void clearData() {
	try {
		RepositoryResult<Statement> statements = rep.getConnection().getStatements(null, null, null, true);
		rep.getConnection().remove(statements);
	} catch (RepositoryException e) {
		e.printStackTrace();
		throw new SparqlTutorialException(e);
	}
}
 
Example 5
Source File: ResourceObjectSupport.java    From anno4j with Apache License 2.0 5 votes vote down vote up
/**
 * Method returns a textual representation of the given ResourceObject in a supported serialisation format.
 *
 * @param format The format which should be printed.
 * @return A textual representation if this object in the format.
 */
@Override
public String getTriples(RDFFormat format) {
    try {
        return getTriples(format, 1, null);
    } catch (RepositoryException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 6
Source File: ResourceObjectSupport.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public void delete() {
    try {
        ObjectConnection connection = getObjectConnection();
        connection.removeDesignation(this, (URI) getResource());
        // explicitly removing the rdf type triple from the repository
        connection.remove(getResource(), null, null);
        connection.remove(null, null, getResource(), null);
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
}
 
Example 7
Source File: StatementSailHandler.java    From anno4j with Apache License 2.0 5 votes vote down vote up
@Override
public void handleStatement(Statement statement) {
    try {
        this.connection.add(statement);
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
}
 
Example 8
Source File: CustomSesameDataset.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public CustomSesameDataset(String sesameServer, String repositoryID) {
	currentRepository = new HTTPRepository(sesameServer, repositoryID);
	try {
		currentRepository.initialize();
	} catch (RepositoryException e) {
		e.printStackTrace();
	}
}
 
Example 9
Source File: CustomSesameDataset.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public void loadDataFromURL(String stringURL) throws RepositoryException, RDFParseException, IOException {
	RepositoryConnection con = null;
	try {
		con = currentRepository.getConnection();
			// upload a URL
			URL url = new URL(stringURL);
			con.add(url, null, RDFFormat.TURTLE);
	} finally {
		try {
			con.close();
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}
}
 
Example 10
Source File: AnnotationSupport.java    From anno4j with Apache License 2.0 4 votes vote down vote up
@Override
public void delete() {
    try {
        ObjectConnection connection = getObjectConnection();

        // deleting an existing body
        if (getBodies() != null) {
            for (Body body : getBodies()) {
                body.delete();
            }
            setBodies(null);
        }

        // deleting existing targets one by one
        if (getTargets() != null) {
            for (Target target : getTargets()) {
                target.delete();
            }
            setTargets(null);
        }

        // deleting possible provenance information
        if (this.getSerializedAt() != null) {
            this.setSerializedAt(null);
        }

        if (this.getSerializedBy() != null) {
            this.setSerializedBy(null);
        }

        if (this.getAnnotatedAt() != null) {
            this.setAnnotatedAt(null);
        }

        if (this.getAnnotatedBy() != null) {
            this.setAnnotatedBy(null);
        }

        if (this.getCreator() != null) {
            this.setCreator(null);
        }

        if (this.getMotivatedBy() != null) {
            this.setMotivatedBy(null);
        }

        if (this.getCreated() != null) {
            this.setCreated(null);
        }

        if (this.getGenerated() != null) {
            this.setGenerated(null);
        }

        if (this.getGenerator() != null) {
            this.setGenerator(null);
        }

        // finally removing this annotation
        connection.removeDesignation(this, (URI) getResource());
        // explicitly removing the rdf type triple from the repository
        connection.remove(getResource(), null, null);
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: TestBigdataGraphEmbeddedRepository.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public BigdataSail getOrCreateRepository(String journalFile) {

		final java.util.Properties props = new java.util.Properties();
		SailRepository repo = null;

		/*
		 * Lax edges allows us to use non-unique edge identifiers
		 */
		props.setProperty(BigdataGraph.Options.LAX_EDGES, "true");

		/*
		 * SPARQL bottom up evaluation semantics can have performance impact.
		 */
		props.setProperty(AbstractTripleStore.Options.BOTTOM_UP_EVALUATION,
				"false");

		if (journalFile == null || !new File(journalFile).exists()) {

			/*
			 * No journal specified or journal does not exist yet at specified
			 * location. Create a new store. (If journal== null an in-memory
			 * store will be created.
			 */
			repo = BigdataSailFactory.createRepository(props, journalFile,
					Option.TextIndex);// , Option.RDR);

		} else {

			/*
			 * Journal already exists at specified location. Open existing
			 * store.
			 */
			repo =  BigdataSailFactory.openRepository(journalFile);

		}

		try {
			repo.initialize();
		} catch (RepositoryException e) {
			e.printStackTrace();
			testPrint(e.toString());
		}

		return (BigdataSail) repo.getSail();
	}