本文整理汇总了Java中org.openrdf.model.vocabulary.OWL.NAMESPACE属性的典型用法代码示例。如果您正苦于以下问题:Java OWL.NAMESPACE属性的具体用法?Java OWL.NAMESPACE怎么用?Java OWL.NAMESPACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openrdf.model.vocabulary.OWL
的用法示例。
在下文中一共展示了OWL.NAMESPACE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeManagedURI
/**
* Tests remove() method with managed URI.
*
* @throws Exception never otherwise the test fails.
*/
@Test
public void removeManagedURI() throws Exception {
final String[] managedNamespaces = {
FOAF.NAMESPACE,
RDFS.NAMESPACE,
OWL.NAMESPACE };
for (final String managedNamespace : managedNamespaces) {
assertTrue(_cut.contains(managedNamespace));
final Value uri = buildResource(managedNamespace + randomString());
final String n3 = NTriplesUtil.toNTriplesString(uri);
_cut.removeValue(uri, _isPredicate);
verify(_dummyIndex).remove(n3);
reset(_dummyIndex);
}
}
示例2: getIdWithManagedURI
/**
* A request is received for a URI with a namespace that belongs to managed domains.
*
* @throws Exception never otherwise the test fails.
*/
@Test
public void getIdWithManagedURI() throws Exception {
final String[] managedNamespaces = {
FOAF.NAMESPACE,
RDFS.NAMESPACE,
OWL.NAMESPACE
};
for (final String managedNamespace : managedNamespaces) {
assertTrue(_cut.contains(managedNamespace));
final Value uri = buildResource(managedNamespace + randomString());
final String n3 = NTriplesUtil.toNTriplesString(uri);
// Make sure the mock index returns "Sorry, we don't have such value".
when(_dummyIndex.get(n3)).thenReturn(ValueDictionaryBase.NOT_SET);
// 1. ask for uri.
byte[] id = _cut.getID(uri, _isPredicate);
// 2. make sure the identifier is well-formed.
assertEquals(KnownURIsDictionary.ID_LENGTH, id.length);
assertEquals(KnownURIsDictionary.KNOWN_URI_MARKER, id[0]);
assertEquals(ValueDictionaryBase.RESOURCE_BYTE_FLAG, id[1]);
// 3. make sure the decoratee wasn't involved in identifier creation.
verify(_decoratee, times(0)).getID(uri, _isPredicate);
verify(_dummyIndex).putQuick(n3, id);
reset(_decoratee, _dummyIndex);
}
}
示例3: testSomeValuesFromInference
public static void testSomeValuesFromInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException,
UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
final String lubm = "http://swat.cse.lehigh.edu/onto/univ-bench.owl#";
log.info("Adding Data");
String insert = "PREFIX lubm: <" + lubm + ">\n"
+ "INSERT DATA { GRAPH <http://updated/test> {\n"
+ " <urn:Department0> a lubm:Department; lubm:subOrganizationOf <urn:University0> .\n"
+ " <urn:ResearchGroup0> a lubm:ResearchGroup; lubm:subOrganizationOf <urn:Department0> .\n"
+ " <urn:Alice> lubm:headOf <urn:Department0> .\n"
+ " <urn:Bob> lubm:headOf <urn:ResearchGroup0> .\n"
+ " <urn:Carol> lubm:worksFor <urn:Department0> .\n"
+ "}}";
Update update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
final String inferQuery = "select distinct ?x { GRAPH <http://updated/test> { ?x a <" + lubm + "Chair> }}";
final String explicitQuery = "prefix lubm: <" + lubm + ">\n"
+ "select distinct ?x { GRAPH <http://updated/test> {\n"
+ " { ?x a lubm:Chair }\n"
+ " UNION\n"
+ " { ?x lubm:headOf [ a lubm:Department ] }\n"
+ "}}";
log.info("Running Explicit Query");
final CountingResultHandler resultHandler = new CountingResultHandler();
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 1);
log.info("Running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 0);
log.info("Adding owl:someValuesFrom Schema");
insert = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n"
+ "PREFIX owl: <" + OWL.NAMESPACE + ">\n"
+ "PREFIX lubm: <" + lubm + ">\n"
+ "INSERT DATA\n"
+ "{ GRAPH <http://updated/test> {\n"
+ " lubm:Chair owl:equivalentClass [ owl:onProperty lubm:headOf ; owl:someValuesFrom lubm:Department ] ."
+ "}}";
update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
log.info("Refreshing InferenceEngine");
((RdfCloudTripleStore) sail).getInferenceEngine().refreshGraph();
log.info("Re-running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 1);
}
示例4: testAllValuesFromInference
public static void testAllValuesFromInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException,
UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
log.info("Adding Data");
String insert = "INSERT DATA\n"
+ "{ GRAPH <http://updated/test> {\n"
+ " <urn:Alice> a <urn:Person> .\n"
+ " <urn:Alice> <urn:hasParent> <urn:Bob> .\n"
+ " <urn:Carol> <urn:hasParent> <urn:Dan> .\n"
+ "}}";
Update update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
final String inferQuery = "select distinct ?x { GRAPH <http://updated/test> { ?x a <urn:Person> }}";
final String explicitQuery = "select distinct ?x { GRAPH <http://updated/test> {\n"
+ " { ?x a <urn:Person> }\n"
+ " UNION {\n"
+ " ?y a <urn:Person> .\n"
+ " ?y <urn:hasParent> ?x .\n"
+ " }\n"
+ "}}";
log.info("Running Explicit Query");
final CountingResultHandler resultHandler = new CountingResultHandler();
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 2);
log.info("Running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 1);
log.info("Adding owl:allValuesFrom Schema");
insert = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n"
+ "PREFIX owl: <" + OWL.NAMESPACE + ">\n"
+ "INSERT DATA\n"
+ "{ GRAPH <http://updated/test> {\n"
+ " <urn:Person> rdfs:subClassOf [ owl:onProperty <urn:hasParent> ; owl:allValuesFrom <urn:Person> ] ."
+ "}}";
update = conn.prepareUpdate(QueryLanguage.SPARQL, insert);
update.execute();
log.info("Refreshing InferenceEngine");
((RdfCloudTripleStore) sail).getInferenceEngine().refreshGraph();
log.info("Re-running Inference-dependent Query");
resultHandler.resetCount();
tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, inferQuery);
tupleQuery.evaluate(resultHandler);
log.info("Result count : " + resultHandler.getCount());
Validate.isTrue(resultHandler.getCount() == 2);
}