本文整理汇总了Java中org.openrdf.repository.http.HTTPRepository类的典型用法代码示例。如果您正苦于以下问题:Java HTTPRepository类的具体用法?Java HTTPRepository怎么用?Java HTTPRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HTTPRepository类属于org.openrdf.repository.http包,在下文中一共展示了HTTPRepository类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStore
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
/**
* Create the store provided by this SailProvider
*
* @return a new instance of the store
*/
@Override
public NotifyingSail createStore() {
String serverUrl = configurationService.getStringConfiguration("backend.http.url");
if(serverUrl == null) {
throw new IllegalStateException("no server URL defined for HTTP backend (property backend.http.url)");
}
log.info("creating new HTTP repository client for server at {}", serverUrl);
httpRepository = new HTTPRepository(serverUrl);
// TODO: would be better to implement a RepositorySail as NotifyingSail wrapper around a repository
Federation store = new Federation();
store.addMember(httpRepository);
return (NotifyingSail)store;
}
示例2: tweetToTripleStore
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
private Boolean tweetToTripleStore(String user_uri, String repository)
throws RepositoryException, RDFParseException, IOException{
File file = new File(TMP_FILE_NAME);
String baseURI = user_uri;
repository = strip(repository);
Repository rep = new HTTPRepository(repository);
ValueFactory f = rep.getValueFactory();
URI context = f.createURI(baseURI);
RepositoryConnection con = rep.getConnection();
try {
con.add(file, baseURI, RDFFormat.RDFXML,context);
}
finally {
con.close();
}
return true;
}
示例3: clearTweets
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
/**
* Removes any possible existing from the repository about the profile
* specified by the account_uri
* @param account_uri
* @param repo
* @throws RepositoryException
*/
private void clearTweets(String account_uri, String repository)
throws RepositoryException {
Repository rep = new HTTPRepository(repository);
ValueFactory f = rep.getValueFactory();
URI context = f.createURI(account_uri);
RepositoryConnection con = rep.getConnection();
try {
con.clear(context);
}
finally {
con.close();
}
}
示例4: sparqlSelect
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
public QueryResultTable sparqlSelect(String endpointURL, String sparqlQuery) {
HTTPRepository endpoint = new HTTPRepository(endpointURL, "");
try {
endpoint.initialize();
RepositoryConnection connection = endpoint.getConnection();
return new RepositoryQueryResultTable(sparqlQuery, connection);
} catch(RepositoryException e) {
throw new ModelRuntimeException(e);
}
}
示例5: init
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
@Override
public Resource init() throws ResourceInstantiationException {
try {
rep = new HTTPRepository(repositoryUrl);
conn = rep.getConnection();
}
catch (RepositoryException e) {
throw new ResourceInstantiationException(e);
}
return this;
}
示例6: findPlaces
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
void findPlaces() throws IOException{
String sesameServer = "http://localhost:8080/openrdf-sesame";
String repositoryID = "legislation";
// Connect to Sesame
Repository repo = new HTTPRepository(sesameServer, repositoryID);
try {
repo.initialize();
} catch (RepositoryException ex) {
Logger.getLogger(EntityIndex.class.getName()).log(Level.SEVERE, null, ex);
}
TupleQueryResult result;
try {
RepositoryConnection con = repo.getConnection();
try {
String queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" +
"\n" +
"SELECT DISTINCT ?name ?id \n" +
"WHERE{\n" +
"?id <http://geo.linkedopendata.gr/gag/ontology/έχει_επίσημο_όνομα> ?name." +
"}\n" ;
//System.out.println(queryString);
TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
result = tupleQuery.evaluate();
try {
// iterate the result set
while (result.hasNext()) {
BindingSet bindingSet = result.next();
String name = bindingSet.getValue("name").toString();
name = name.replace("^^<http://www.w3.org/2001/XMLSchema#string>", "");
name = trimDoubleQuotes(name);
String id = bindingSet.getValue("id").toString();
addDoc(indexWriter,name,id);
System.out.println(name);
}
}
finally {
result.close();
}
}
finally {
con.close();
}
}
catch (OpenRDFException e) {
// handle exception
}
}
示例7: findOrganizations
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
void findOrganizations() throws IOException{
String sesameServer = "http://localhost:8080/openrdf-sesame";
String repositoryID = "legislation";
// Connect to Sesame
Repository repo = new HTTPRepository(sesameServer, repositoryID);
try {
repo.initialize();
} catch (RepositoryException ex) {
Logger.getLogger(EntityIndex.class.getName()).log(Level.SEVERE, null, ex);
}
TupleQueryResult result;
try {
RepositoryConnection con = repo.getConnection();
try {
String queryString = "PREFIX pb: <http://geo.linkedopendata.gr/public-buildings/ontology/>\n" +
"\n" +
"SELECT DISTINCT ?name ?id \n" +
"WHERE{\n" +
"?id pb:έχει_όνομα_υπηρεσίας ?name." +
"}\n" ;
//System.out.println(queryString);
TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
result = tupleQuery.evaluate();
try {
// iterate the result set
while (result.hasNext()) {
BindingSet bindingSet = result.next();
String name = bindingSet.getValue("name").toString();
name = name.replace("^^<http://www.w3.org/2001/XMLSchema#string>", "");
name = trimDoubleQuotes(name);
String id = bindingSet.getValue("id").toString();
addDoc(indexWriter,name,id);
System.out.println(name);
}
}
finally {
result.close();
}
}
finally {
con.close();
}
}
catch (OpenRDFException e) {
// handle exception
}
}
示例8: findPeople
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
void findPeople() throws IOException{
String sesameServer = "http://localhost:8080/openrdf-sesame";
String repositoryID = "dbpedia";
// Connect to Sesame
Repository repo = new HTTPRepository(sesameServer, repositoryID);
try {
repo.initialize();
} catch (RepositoryException ex) {
Logger.getLogger(EntityIndex.class.getName()).log(Level.SEVERE, null, ex);
}
TupleQueryResult result;
try {
RepositoryConnection con = repo.getConnection();
try {
String queryString = "PREFIX ontology: <http://dbpedia.org/ontology/>\n" +
"PREFIX prop: <http://el.dbpedia.org/property/>\n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
"\n" +
"select distinct ?id ?name ?image\n" +
"where {\n" +
"?id rdf:type ontology:Politician.\n" +
"?id foaf:name ?name.\n" +
"\n" +
"{?id prop:εθνικότητα <http://el.dbpedia.org/resource/Έλληνας>} UNION {?id prop:εθνικότητα \"Ελληνική\"@el} UNION {?id prop:εθνικότητα <http://el.dbpedia.org/resource/Έλληνες>}\n" +
"\n" +
"}";
//System.out.println(queryString);
TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
result = tupleQuery.evaluate();
try {
// iterate the result set
while (result.hasNext()) {
BindingSet bindingSet = result.next();
String name = bindingSet.getValue("name").toString();
name = name.replace("^^<http://www.w3.org/2001/XMLSchema#string>", "");
name = this.capitalize(trimDoubleQuotes(name.replace("@el", "")));
String id = bindingSet.getValue("id").toString().replace("resource", "page");
addDoc(indexWriter,name,id);
System.out.println(name);
}
}
finally {
result.close();
}
}
finally {
con.close();
}
}
catch (OpenRDFException e) {
// handle exception
}
}
示例9: ConnectionToVirtuoso
import org.openrdf.repository.http.HTTPRepository; //导入依赖的package包/类
public RepositoryConnection ConnectionToVirtuoso() throws RepositoryException {
String endpointURL = "http://virtuoso.ct.infn.it:8890/sparql";
// String endpointURL ="http://virtuoso.ct.infn.it:8896/chain-reds-kb/sparql";
Repository myRepository = new HTTPRepository(endpointURL, "");
myRepository.initialize();
RepositoryConnection virtuosoConnection = myRepository.getConnection();
System.out.println("Connessione a Virtuoso");
return virtuosoConnection;
}