Merge branch 'feature/pelletRemoval' into develop
This commit is contained in:
commit
f4f51a096f
17 changed files with 524 additions and 1181 deletions
|
@ -188,7 +188,3 @@ webapp/src/edu/ucsf/vitro/opensocial/GadgetViewRequirements.java
|
||||||
webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java
|
webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java
|
||||||
webapp/src/edu/ucsf/vitro/opensocial/PreparedGadget.java
|
webapp/src/edu/ucsf/vitro/opensocial/PreparedGadget.java
|
||||||
webapp/web/js/openSocial/shindig.js
|
webapp/web/js/openSocial/shindig.js
|
||||||
|
|
||||||
# This is a modified version of a Jena source file.
|
|
||||||
# It is required to make Jena 2.10.1 compatible with Pellet 2.3.1
|
|
||||||
webapp/src/com/hp/hpl/jena/reasoner/BaseInfGraph.java
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,544 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.hp.hpl.jena.reasoner;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.graph.*;
|
|
||||||
import com.hp.hpl.jena.graph.compose.MultiUnion;
|
|
||||||
import com.hp.hpl.jena.graph.impl.*;
|
|
||||||
import com.hp.hpl.jena.shared.*;
|
|
||||||
import com.hp.hpl.jena.util.iterator.*;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A base level implementation of the InfGraph interface.
|
|
||||||
*/
|
|
||||||
public abstract class BaseInfGraph extends GraphBase implements InfGraph {
|
|
||||||
|
|
||||||
/** The Reasoner instance which performs all inferences and Tbox lookups */
|
|
||||||
protected Reasoner reasoner;
|
|
||||||
|
|
||||||
/** The graph of raw data which is being reasoned over */
|
|
||||||
protected FGraph fdata;
|
|
||||||
|
|
||||||
/** Flag, if set to true then derivations are recorded */
|
|
||||||
protected boolean recordDerivations;
|
|
||||||
|
|
||||||
/** Flag to record if the preparation call has been made and so the graph is ready for queries */
|
|
||||||
protected volatile boolean isPrepared = false;
|
|
||||||
|
|
||||||
/** version count */
|
|
||||||
protected volatile int version = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Inference graphs share the prefix-mapping of their underlying raw graph.
|
|
||||||
@see com.hp.hpl.jena.graph.Graph#getPrefixMapping()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PrefixMapping getPrefixMapping()
|
|
||||||
{ return getRawGraph().getPrefixMapping(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param data the raw data file to be augmented with entailments
|
|
||||||
* @param reasoner the engine, with associated tbox data, whose find interface
|
|
||||||
* can be used to extract all entailments from the data.
|
|
||||||
*/
|
|
||||||
public BaseInfGraph(Graph data, Reasoner reasoner) {
|
|
||||||
super( );
|
|
||||||
this.fdata = new FGraph( data );
|
|
||||||
this.reasoner = reasoner;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Answer the InfCapabilities of this InfGraph.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Capabilities getCapabilities() {
|
|
||||||
if (capabilities == null) {
|
|
||||||
return getReasoner().getGraphCapabilities();
|
|
||||||
} else {
|
|
||||||
return capabilities;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
An InfCapabilities notes that size may not be accurate, and some
|
|
||||||
triples may be irremovable.
|
|
||||||
|
|
||||||
TODO accomodate the properties of the base graph, too.
|
|
||||||
*/
|
|
||||||
public static class InfCapabilities extends AllCapabilities
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean sizeAccurate() { return false; }
|
|
||||||
@Override
|
|
||||||
public boolean deleteAllowed( boolean every ) { return !every; }
|
|
||||||
@Override
|
|
||||||
public boolean iteratorRemoveAllowed() { return false; }
|
|
||||||
@Override
|
|
||||||
public boolean findContractSafe() { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
An InfCapabilities notes that size may not be accurate, and some
|
|
||||||
triples may be irremovable.
|
|
||||||
|
|
||||||
TODO accomodate the properties of the base graph, too.
|
|
||||||
*/
|
|
||||||
public static class InfFindSafeCapabilities extends InfCapabilities
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean findContractSafe() { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@deprecated Bulk update operations are going to be removed.
|
|
||||||
@see GraphUtil for convenience helpers.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public BulkUpdateHandler getBulkUpdateHandler()
|
|
||||||
{
|
|
||||||
if (bulkHandler == null) bulkHandler = new InfBulkUpdateHandler( this );
|
|
||||||
return bulkHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
InfBulkUpdateHandler - a bulk update handler specialised for inference
|
|
||||||
graphs by code for <code>removeAll()</code>.
|
|
||||||
*/
|
|
||||||
static class InfBulkUpdateHandler extends SimpleBulkUpdateHandler
|
|
||||||
{
|
|
||||||
public InfBulkUpdateHandler( BaseInfGraph graph )
|
|
||||||
{ super(graph); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void remove( Node s, Node p, Node o )
|
|
||||||
{
|
|
||||||
BaseInfGraph g = (BaseInfGraph) graph;
|
|
||||||
g.getRawGraph().remove( s, p, o );
|
|
||||||
g.discardState();
|
|
||||||
g.rebind();
|
|
||||||
manager.notifyEvent( graph, GraphEvents.remove( s, p, o ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void removeAll()
|
|
||||||
{
|
|
||||||
BaseInfGraph g = (BaseInfGraph) graph;
|
|
||||||
g.getRawGraph().clear();
|
|
||||||
g.discardState();
|
|
||||||
g.rebind();
|
|
||||||
g.getEventManager().notifyEvent( g, GraphEvents.removeAll );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove( Node s, Node p, Node o )
|
|
||||||
{
|
|
||||||
getRawGraph().remove( s, p, o );
|
|
||||||
discardState();
|
|
||||||
rebind();
|
|
||||||
getEventManager().notifyEvent( this, GraphEvents.remove( s, p, o ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
getRawGraph().clear() ;
|
|
||||||
discardState();
|
|
||||||
rebind();
|
|
||||||
getEventManager().notifyEvent( this, GraphEvents.removeAll );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TransactionHandler getTransactionHandler()
|
|
||||||
{ return new InfTransactionHandler( this ); }
|
|
||||||
|
|
||||||
public static class InfTransactionHandler
|
|
||||||
extends TransactionHandlerBase implements TransactionHandler
|
|
||||||
{
|
|
||||||
protected final BaseInfGraph base;
|
|
||||||
|
|
||||||
public InfTransactionHandler( BaseInfGraph base )
|
|
||||||
{ this.base = base; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean transactionsSupported()
|
|
||||||
{ return getBaseHandler().transactionsSupported(); }
|
|
||||||
|
|
||||||
protected TransactionHandler getBaseHandler()
|
|
||||||
{ return base.getRawGraph().getTransactionHandler(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void begin()
|
|
||||||
{ getBaseHandler().begin(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void abort()
|
|
||||||
{ getBaseHandler().abort();
|
|
||||||
base.rebind(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void commit()
|
|
||||||
{ getBaseHandler().commit(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
discard any state that depends on the content of fdata, because
|
|
||||||
it's just been majorly trashed, solid gone.
|
|
||||||
*/
|
|
||||||
protected void discardState()
|
|
||||||
{}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the raw RDF data Graph being processed (i.e. the argument
|
|
||||||
* to the Reasonder.bind call that created this InfGraph).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Graph getRawGraph() {
|
|
||||||
return fdata.getGraph();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the Reasoner which is being used to answer queries to this graph.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Reasoner getReasoner() {
|
|
||||||
return reasoner;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the underlying data graph for this inference graph and start any
|
|
||||||
* inferences over again. This is primarily using in setting up ontology imports
|
|
||||||
* processing to allow an imports multiunion graph to be inserted between the
|
|
||||||
* inference graph and the raw data, before processing.
|
|
||||||
* @param data the new raw data graph
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void rebind(Graph data) {
|
|
||||||
fdata = new FGraph(data);
|
|
||||||
isPrepared = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cause the inference graph to reconsult the underlying graph to take
|
|
||||||
* into account changes. Normally changes are made through the InfGraph's add and
|
|
||||||
* remove calls are will be handled appropriately. However, in some cases changes
|
|
||||||
* are made "behind the InfGraph's back" and this forces a full reconsult of
|
|
||||||
* the changed data.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void rebind() {
|
|
||||||
version++;
|
|
||||||
isPrepared = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset any internal caches. Some systems, such as the tabled backchainer,
|
|
||||||
* retain information after each query. A reset will wipe this information preventing
|
|
||||||
* unbounded memory use at the expense of more expensive future queries. A reset
|
|
||||||
* does not cause the raw data to be reconsulted and so is less expensive than a rebind.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
version++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform any initial processing and caching. This call is optional. Most
|
|
||||||
* engines either have negligable set up work or will perform an implicit
|
|
||||||
* "prepare" if necessary. The call is provided for those occasions where
|
|
||||||
* substantial preparation work is possible (e.g. running a forward chaining
|
|
||||||
* rule system) and where an application might wish greater control over when
|
|
||||||
* this prepration is done.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void prepare() {
|
|
||||||
// Default is to do no preparation
|
|
||||||
isPrepared = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a derivations graph. The rule reasoners typically create a
|
|
||||||
* graph containing those triples added to the base graph due to rule firings.
|
|
||||||
* In some applications it can useful to be able to access those deductions
|
|
||||||
* directly, without seeing the raw data which triggered them. In particular,
|
|
||||||
* this allows the forward rules to be used as if they were rewrite transformation
|
|
||||||
* rules.
|
|
||||||
* @return the deductions graph, if relevant for this class of inference
|
|
||||||
* engine or null if not.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Graph getDeductionsGraph() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test a global boolean property of the graph. This might included
|
|
||||||
* properties like consistency, OWLSyntacticValidity etc.
|
|
||||||
* It remains to be seen what level of generality is needed here. We could
|
|
||||||
* replace this by a small number of specific tests for common concepts.
|
|
||||||
* @param property the URI of the property to be tested
|
|
||||||
* @return a Node giving the value of the global property, this may
|
|
||||||
* be a boolean literal, some other literal value (e.g. a size).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Node getGlobalProperty(Node property) {
|
|
||||||
throw new ReasonerException("Global property not implemented: " + property);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A convenience version of getGlobalProperty which can only return
|
|
||||||
* a boolean result.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean testGlobalProperty(Node property) {
|
|
||||||
Node resultNode = getGlobalProperty(property);
|
|
||||||
if (resultNode.isLiteral()) {
|
|
||||||
Object result = resultNode.getLiteralValue();
|
|
||||||
if (result instanceof Boolean) {
|
|
||||||
return ((Boolean)result).booleanValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new ReasonerException("Global property test returned non-boolean value" +
|
|
||||||
"\nTest was: " + property +
|
|
||||||
"\nResult was: " + resultNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the consistency of the bound data. This normally tests
|
|
||||||
* the validity of the bound instance data against the bound
|
|
||||||
* schema data.
|
|
||||||
* @return a ValidityReport structure
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ValidityReport validate() {
|
|
||||||
checkOpen();
|
|
||||||
return new StandardValidityReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An extension of the Graph.find interface which allows the caller to
|
|
||||||
* encode complex expressions in RDF and then refer to those expressions
|
|
||||||
* within the query triple. For example, one might encode a class expression
|
|
||||||
* and then ask if there are any instances of this class expression in the
|
|
||||||
* InfGraph.
|
|
||||||
* @param subject the subject Node of the query triple, may be a Node in
|
|
||||||
* the graph or a node in the parameter micro-graph or null
|
|
||||||
* @param property the property to be retrieved or null
|
|
||||||
* @param object the object Node of the query triple, may be a Node in
|
|
||||||
* the graph or a node in the parameter micro-graph.
|
|
||||||
* @param param a small graph encoding an expression which the subject and/or
|
|
||||||
* object nodes refer.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ExtendedIterator<Triple> find(Node subject, Node property, Node object, Graph param) {
|
|
||||||
return cloneWithPremises(param).find(subject, property, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an iterator over Triples.
|
|
||||||
*
|
|
||||||
* <p>This code used to have the .filterKeep component uncommented. We
|
|
||||||
* think this is because of earlier history, before .matches on a literal node
|
|
||||||
* was implemented as sameValueAs rather than equals. If it turns out that
|
|
||||||
* the filter is needed, it can be commented back in, AND a corresponding
|
|
||||||
* filter added to find(Node x 3) -- and test cases, of course.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ExtendedIterator<Triple> graphBaseFind(TripleMatch m) {
|
|
||||||
return graphBaseFind(m.getMatchSubject(), m.getMatchPredicate(), m.getMatchObject())
|
|
||||||
// .filterKeep(new TripleMatchFilter(m.asTriple()))
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an iterator over Triples.
|
|
||||||
* This implementation assumes that the underlying findWithContinuation
|
|
||||||
* will have also consulted the raw data.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) {
|
|
||||||
return findWithContinuation(new TriplePattern(subject, property, object), fdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extended find interface used in situations where the implementator
|
|
||||||
* may or may not be able to answer the complete query. It will
|
|
||||||
* attempt to answer the pattern but if its answers are not known
|
|
||||||
* to be complete then it will also pass the request on to the nested
|
|
||||||
* Finder to append more results.
|
|
||||||
* @param pattern a TriplePattern to be matched against the data
|
|
||||||
* @param continuation either a Finder or a normal Graph which
|
|
||||||
* will be asked for additional match results if the implementor
|
|
||||||
* may not have completely satisfied the query.
|
|
||||||
*/
|
|
||||||
abstract public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic pattern lookup interface.
|
|
||||||
* This implementation assumes that the underlying findWithContinuation
|
|
||||||
* will have also consulted the raw data.
|
|
||||||
* @param pattern a TriplePattern to be matched against the data
|
|
||||||
* @return a ExtendedIterator over all Triples in the data set
|
|
||||||
* that match the pattern
|
|
||||||
*/
|
|
||||||
public ExtendedIterator<Triple> find(TriplePattern pattern) {
|
|
||||||
checkOpen();
|
|
||||||
return findWithContinuation(pattern, fdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch on/off drivation logging
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setDerivationLogging(boolean logOn) {
|
|
||||||
recordDerivations = logOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the derivation of the given triple (which is the result of
|
|
||||||
* some previous find operation).
|
|
||||||
* Not all reasoneers will support derivations.
|
|
||||||
* @return an iterator over Derivation records or null if there is no derivation information
|
|
||||||
* available for this triple.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Iterator<Derivation> getDerivation(Triple triple) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of triples in the just the base graph
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int graphBaseSize() {
|
|
||||||
checkOpen();
|
|
||||||
return fdata.getGraph().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Answer true iff this graph is empty. [Used to be in QueryHandler, but moved in
|
|
||||||
here because it's a more primitive operation.]
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return fdata.getGraph().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free all resources, any further use of this Graph is an error.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
if (!closed) {
|
|
||||||
fdata.getGraph().close();
|
|
||||||
fdata = null;
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a version stamp for this graph which can be
|
|
||||||
* used to fast-fail concurrent modification exceptions.
|
|
||||||
*/
|
|
||||||
public int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add one triple to the data graph, run any rules triggered by
|
|
||||||
* the new data item, recursively adding any generated triples.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void performAdd(Triple t) {
|
|
||||||
version++;
|
|
||||||
this.requirePrepared();
|
|
||||||
fdata.getGraph().add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the triple t (if possible) from the set belonging to this graph.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void performDelete(Triple t) {
|
|
||||||
version++;
|
|
||||||
this.requirePrepared();
|
|
||||||
fdata.getGraph().delete(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the schema graph, if any, bound into this inference graph.
|
|
||||||
*/
|
|
||||||
public abstract Graph getSchemaGraph();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a new inference graph which is a clone of the current graph
|
|
||||||
* together with an additional set of data premises. The default
|
|
||||||
* implementation loses ALL partial deductions so far. Some subclasses
|
|
||||||
* may be able to a more efficient job.
|
|
||||||
*/
|
|
||||||
public InfGraph cloneWithPremises(Graph premises) {
|
|
||||||
MultiUnion union = new MultiUnion();
|
|
||||||
Graph raw = getRawGraph();
|
|
||||||
union.addGraph( raw );
|
|
||||||
union.setBaseGraph( raw );
|
|
||||||
union.addGraph( premises );
|
|
||||||
Graph schema = getSchemaGraph();
|
|
||||||
if (schema != null) {
|
|
||||||
if (schema instanceof BaseInfGraph) {
|
|
||||||
BaseInfGraph ischema = (BaseInfGraph)schema;
|
|
||||||
Graph sschema = ischema.getSchemaGraph();
|
|
||||||
if (sschema != null) union.addGraph( sschema );
|
|
||||||
Graph rschema = ischema.getRawGraph();
|
|
||||||
if (rschema != null) union.addGraph( rschema );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return getReasoner().bind(union);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Answer true iff this graph has been through the <code>prepare()</code> step.
|
|
||||||
For testing purposes.
|
|
||||||
* @return Whether the graph is prepared
|
|
||||||
*/
|
|
||||||
public synchronized boolean isPrepared()
|
|
||||||
{ return isPrepared; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset prepared state to false
|
|
||||||
*/
|
|
||||||
protected synchronized void setPreparedState(boolean state) {
|
|
||||||
this.isPrepared = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the graph is prepared and calls {@link #prepare()} if it is not
|
|
||||||
*/
|
|
||||||
protected synchronized void requirePrepared() {
|
|
||||||
if (!this.isPrepared) this.prepare();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -297,9 +297,6 @@ public class JenaAdminActions extends BaseEditController {
|
||||||
} else if (request.getParameter("inferences") != null) {
|
} else if (request.getParameter("inferences") != null) {
|
||||||
memoryModel = ModelAccess.on(getServletContext()).getOntModel(FULL_INFERENCES);
|
memoryModel = ModelAccess.on(getServletContext()).getOntModel(FULL_INFERENCES);
|
||||||
System.out.println("inferenceOntModel");
|
System.out.println("inferenceOntModel");
|
||||||
} else if (request.getParameter("pellet") != null) {
|
|
||||||
memoryModel = (OntModel) getServletContext().getAttribute("pelletOntModel");
|
|
||||||
System.out.println("pelletOntModel");
|
|
||||||
} else {
|
} else {
|
||||||
memoryModel = ModelAccess.on(getServletContext()).getOntModel();
|
memoryModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
System.out.println("jenaOntModel");
|
System.out.println("jenaOntModel");
|
||||||
|
|
|
@ -17,10 +17,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -38,8 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.mindswap.pellet.exceptions.InconsistentOntologyException;
|
import org.semanticweb.owlapi.reasoner.InconsistentOntologyException;
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.Individual;
|
import com.hp.hpl.jena.ontology.Individual;
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
@ -837,12 +834,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
|
|
||||||
private long doExecuteSparql(VitroRequest vreq) {
|
private long doExecuteSparql(VitroRequest vreq) {
|
||||||
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
OntModel jenaOntModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
OntModel source = null;
|
OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
||||||
if ("pellet".equals(vreq.getParameter("reasoning"))) {
|
|
||||||
source = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
} else {
|
|
||||||
source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
|
||||||
}
|
|
||||||
String[] sourceModel = vreq.getParameterValues("sourceModelName");
|
String[] sourceModel = vreq.getParameterValues("sourceModelName");
|
||||||
for (int i=0; i<sourceModel.length; i++) {
|
for (int i=0; i<sourceModel.length; i++) {
|
||||||
Model m = getModel(sourceModel[i],vreq);
|
Model m = getModel(sourceModel[i],vreq);
|
||||||
|
@ -1184,21 +1176,6 @@ public class JenaIngestController extends BaseEditController {
|
||||||
vreq.getRequestDispatcher("/dumpRestore").forward(vreq, response);
|
vreq.getRequestDispatcher("/dumpRestore").forward(vreq, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CollationSort implements Comparator<String> {
|
|
||||||
|
|
||||||
Collator collator;
|
|
||||||
|
|
||||||
public CollationSort(VitroRequest vreq) {
|
|
||||||
this.collator = vreq.getCollator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(String s1, String s2) {
|
|
||||||
return collator.compare(s1, s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Model getModel(String name, HttpServletRequest request) {
|
public static Model getModel(String name, HttpServletRequest request) {
|
||||||
return getModelMaker(request).getModel(name);
|
return getModelMaker(request).getModel(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class ConfiguredReasonerListener implements ModelChangedListener {
|
||||||
// It originally assumed that only resources would be in object
|
// It originally assumed that only resources would be in object
|
||||||
// position, but cardinality axioms will have e.g. nonNegativeIntegers.
|
// position, but cardinality axioms will have e.g. nonNegativeIntegers.
|
||||||
// This is a temporary workaround: all cardinality statements will
|
// This is a temporary workaround: all cardinality statements will
|
||||||
// be exposed to Pellet, regardless of configuration patterns.
|
// be exposed to the TBox reasoner, regardless of configuration patterns.
|
||||||
private boolean hasCardinalityPredicate(Statement stmt) {
|
private boolean hasCardinalityPredicate(Statement stmt) {
|
||||||
return (stmt.getPredicate().equals(OWL.cardinality)
|
return (stmt.getPredicate().equals(OWL.cardinality)
|
||||||
|| stmt.getPredicate().equals(OWL.minCardinality) || stmt
|
|| stmt.getPredicate().equals(OWL.minCardinality) || stmt
|
||||||
|
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.tboxreasoner;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
|
@ -25,8 +22,6 @@ public class ReasonerConfiguration {
|
||||||
private boolean reasonOnAllDatatypePropertyStatements = false;
|
private boolean reasonOnAllDatatypePropertyStatements = false;
|
||||||
private boolean queryForAllDatatypeProperties = false;
|
private boolean queryForAllDatatypeProperties = false;
|
||||||
|
|
||||||
private OntModelSpec ontModelSpec = PelletReasonerFactory.THE_SPEC;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default reasoner configuration is designed to provide acceptable performance on larger knowledge bases.
|
* The default reasoner configuration is designed to provide acceptable performance on larger knowledge bases.
|
||||||
* It will classify and realize, and add inferred disjointWith statements.
|
* It will classify and realize, and add inferred disjointWith statements.
|
||||||
|
@ -54,8 +49,6 @@ public class ReasonerConfiguration {
|
||||||
public static ReasonerConfiguration PSEUDOCOMPLETE_IGNORE_DATAPROPERTIES;
|
public static ReasonerConfiguration PSEUDOCOMPLETE_IGNORE_DATAPROPERTIES;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
|
|
||||||
//ask the reasoner only to classify, realize, and infer disjointWith statements (based on a somewhat incomplete information)
|
//ask the reasoner only to classify, realize, and infer disjointWith statements (based on a somewhat incomplete information)
|
||||||
DEFAULT = new ReasonerConfiguration();
|
DEFAULT = new ReasonerConfiguration();
|
||||||
HashSet<ReasonerStatementPattern> defaultInferenceDrivingPatternAllowSet = new HashSet<>();
|
HashSet<ReasonerStatementPattern> defaultInferenceDrivingPatternAllowSet = new HashSet<>();
|
||||||
|
@ -164,14 +157,6 @@ public class ReasonerConfiguration {
|
||||||
this.queryForAllDatatypeProperties = boole;
|
this.queryForAllDatatypeProperties = boole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OntModelSpec getOntModelSpec() {
|
|
||||||
return this.ontModelSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOntModelSpec(OntModelSpec spec) {
|
|
||||||
this.ontModelSpec = spec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIncrementalReasoningEnabled() {
|
public boolean isIncrementalReasoningEnabled() {
|
||||||
return this.incrementalReasoningEnabled;
|
return this.incrementalReasoningEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.apache.log4j.Level;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
|
@ -16,10 +15,9 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper {
|
||||||
|
|
||||||
long delay = 50;
|
long delay = 50;
|
||||||
|
|
||||||
|
@ -46,21 +44,16 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
* basic scenarios around adding abox data
|
* basic scenarios around adding abox data
|
||||||
*
|
*
|
||||||
* Create a Tbox with property P inverseOf property Q.
|
* Create a Tbox with property P inverseOf property Q.
|
||||||
* Pellet will compute TBox inferences. Add a statement
|
* Add a statement a P b, and verify that b Q a is inferred.
|
||||||
* a P b, and verify that b Q a is inferred.
|
* Add a statement c Q d and verify that d Q c is inferred.
|
||||||
* Add a statement c Q d and verify that d Q c
|
|
||||||
* is inferred.
|
|
||||||
*/
|
*/
|
||||||
public void addABoxAssertion1(boolean sameAs ) {
|
public void addABoxAssertion1(boolean sameAs ) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
setInverse(P, Q);
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -109,13 +102,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
public void addABoxAssertion2(boolean sameAs ) {
|
public void addABoxAssertion2(boolean sameAs ) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
P.setLabel("property P", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -153,12 +143,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
public void addABoxAssertion3(boolean sameAs) {
|
public void addABoxAssertion3(boolean sameAs) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
setInverse(P, Q);
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -197,16 +185,13 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
public void addABoxAssertion4( boolean sameAs ) {
|
public void addABoxAssertion4( boolean sameAs ) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty R = tBox.createOntProperty("http://test.vivo/R");
|
OntProperty R = createObjectProperty(tBox, "http://test.vivo/R", "property R");
|
||||||
R.setLabel("property R", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
setInverse(R, Q);
|
||||||
Q.setLabel("property Q", "en-US");
|
setEquivalent(R, P);
|
||||||
|
|
||||||
R.addEquivalentProperty(P);
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -250,15 +235,12 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
public void removedABoxAssertion1(boolean sameAs) {
|
public void removedABoxAssertion1(boolean sameAs) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
Q.setLabel("property Q", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty T = tBox.createOntProperty("http://test.vivo/T");
|
setInverse(P, T);
|
||||||
Q.setLabel("property T", "en-US");
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
P.addInverseOf(T);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -307,19 +289,13 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
public void removedABoxAssertion2(boolean sameAs) {
|
public void removedABoxAssertion2(boolean sameAs) {
|
||||||
|
|
||||||
// set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
Q.setLabel("property Q", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty T = tBox.createOntProperty("http://test.vivo/T");
|
setInverse(T, Q);
|
||||||
Q.setLabel("property T", "en-US");
|
setEquivalent(P, T);
|
||||||
P.addInverseOf(Q);
|
|
||||||
P.addEquivalentProperty(T);
|
|
||||||
|
|
||||||
// not clear what these will do
|
|
||||||
tBox.rebind();
|
|
||||||
tBox.prepare();
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -360,15 +336,11 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void removedABoxAssertion3(boolean sameAs) {
|
public void removedABoxAssertion3(boolean sameAs) {
|
||||||
|
|
||||||
//set up the tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
setInverse(P, Q);
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
P.addInverseOf(Q);
|
|
||||||
|
|
||||||
tBox.rebind(); // not sure what effect this has
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -410,12 +382,10 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void addTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
public void addTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
||||||
|
|
||||||
// Set up the TBox.
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -444,7 +414,7 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
// Assert P and Q as inverses and wait for
|
// Assert P and Q as inverses and wait for
|
||||||
// SimpleReasonerTBoxListener thread to end
|
// SimpleReasonerTBoxListener thread to end
|
||||||
|
|
||||||
Q.addInverseOf(P);
|
setInverse(P, Q);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -473,14 +443,11 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void removeTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
public void removeTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
||||||
|
|
||||||
// set up the tbox.
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/propP");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
P.setLabel("property P", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/propQ");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
Q.addInverseOf(P);
|
|
||||||
|
|
||||||
// this is the model to receive abox inferences
|
// this is the model to receive abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -505,7 +472,7 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
// Remove P and Q inverse relationship and wait for
|
// Remove P and Q inverse relationship and wait for
|
||||||
// SimpleReasoner TBox thread to end.
|
// SimpleReasoner TBox thread to end.
|
||||||
|
|
||||||
Q.removeInverseProperty(P);
|
removeInverse(P, Q);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -532,20 +499,14 @@ public class SimpleReasonerInversePropertyTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void recomputeABox1(boolean sameAs) throws InterruptedException {
|
public void recomputeABox1(boolean sameAs) throws InterruptedException {
|
||||||
|
|
||||||
// set up tbox
|
// set up the tbox
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/propP");
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
P.setLabel("property P", "en-US");
|
setInverse(P, Q);
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/propQ");
|
OntProperty X = createObjectProperty(tBox, "http://test.vivo/X", "property X");
|
||||||
Q.setLabel("property Q", "en-US");
|
OntProperty Y = createObjectProperty(tBox, "http://test.vivo/Y", "property Y");
|
||||||
Q.addInverseOf(P);
|
setInverse(X, Y);
|
||||||
|
|
||||||
OntProperty X = tBox.createOntProperty("http://test.vivo/propX");
|
|
||||||
P.setLabel("property X", "en-US");
|
|
||||||
OntProperty Y = tBox.createOntProperty("http://test.vivo/propY");
|
|
||||||
Q.setLabel("property Y", "en-US");
|
|
||||||
X.addInverseOf(Y);
|
|
||||||
|
|
||||||
// create abox and abox inf model and register simplereasoner
|
// create abox and abox inf model and register simplereasoner
|
||||||
// with abox.
|
// with abox.
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.apache.log4j.Level;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
|
@ -23,9 +22,7 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
public class SimpleReasonerPluginTest extends SimpleReasonerTBoxHelper {
|
||||||
|
|
||||||
public class SimpleReasonerPluginTest extends AbstractTestClass {
|
|
||||||
long delay = 50;
|
long delay = 50;
|
||||||
|
|
||||||
private final static String DEFAULT_NS = "http://vivoweb.org/individual/";
|
private final static String DEFAULT_NS = "http://vivoweb.org/individual/";
|
||||||
|
@ -53,7 +50,7 @@ public class SimpleReasonerPluginTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void test1() {
|
public void test1() {
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
|
||||||
OntProperty authorInAuthorship = tBox.createObjectProperty(authorInAuthorship_URI);
|
OntProperty authorInAuthorship = tBox.createObjectProperty(authorInAuthorship_URI);
|
||||||
OntProperty linkedAuthor = tBox.createObjectProperty(linkedAuthor_URI);
|
OntProperty linkedAuthor = tBox.createObjectProperty(linkedAuthor_URI);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.apache.log4j.Level;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
||||||
import com.hp.hpl.jena.ontology.OntClass;
|
import com.hp.hpl.jena.ontology.OntClass;
|
||||||
|
@ -21,10 +20,9 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
||||||
|
|
||||||
long delay = 50;
|
long delay = 50;
|
||||||
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
||||||
|
@ -43,21 +41,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
//*/
|
//*/
|
||||||
@Test
|
@Test
|
||||||
public void addSameAsABoxAssertion1() {
|
public void addSameAsABoxAssertion1() {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
@ -129,21 +117,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void removeSameAsABoxAssertion1() {
|
public void removeSameAsABoxAssertion1() {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/data1");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/data2");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
@ -186,21 +164,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void addABoxAssertion1() {
|
public void addABoxAssertion1() {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
@ -283,21 +251,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void disabledSameAs() {
|
public void disabledSameAs() {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
@ -369,7 +327,7 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void addABoxAssertion2() {
|
public void addABoxAssertion2() {
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
|
||||||
OntProperty desc = tBox.createDatatypeProperty("http://test.vivo/desc");
|
OntProperty desc = tBox.createDatatypeProperty("http://test.vivo/desc");
|
||||||
desc.setLabel("property desc", "en-US");
|
desc.setLabel("property desc", "en-US");
|
||||||
|
@ -403,21 +361,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void removeABoxAssertion1() {
|
public void removeABoxAssertion1() {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
@ -453,18 +401,12 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void tBoxInverseAssertion1() throws InterruptedException {
|
public void tBoxInverseAssertion1() throws InterruptedException {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Create ABox and Inference models and register
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
// Pellet will compute TBox inferences
|
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
|
|
||||||
OntProperty P = tBox.createOntProperty("http://test.vivo/P");
|
|
||||||
P.setLabel("property P", "en-US");
|
|
||||||
|
|
||||||
OntProperty Q = tBox.createOntProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -482,7 +424,7 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
aBox.add(a,P,b);
|
aBox.add(a,P,b);
|
||||||
aBox.add(a, OWL.sameAs,b);
|
aBox.add(a, OWL.sameAs,b);
|
||||||
|
|
||||||
Q.addInverseOf(P);
|
setInverse(Q, P);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -493,7 +435,7 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
Assert.assertTrue(inf.contains(b,P,b));
|
Assert.assertTrue(inf.contains(b,P,b));
|
||||||
Assert.assertTrue(inf.contains(a,Q,a));
|
Assert.assertTrue(inf.contains(a,Q,a));
|
||||||
|
|
||||||
Q.removeInverseProperty(P);
|
removeInverse(Q, P);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -513,19 +455,12 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
* a sameAs individual.
|
* a sameAs individual.
|
||||||
*/
|
*/
|
||||||
//@Test
|
//@Test
|
||||||
public void tBoxTypeAssertion1() throws InterruptedException {
|
public void tBoxTypeAssertion1() {
|
||||||
|
|
||||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
addSubclass(classA, classB);
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
classA.addSubClass(classB);
|
|
||||||
|
|
||||||
// this is the model to receive inferences
|
// this is the model to receive inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -560,17 +495,13 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
//@Test
|
//@Test
|
||||||
public void tBoxSubclassAssertion1() throws InterruptedException {
|
public void tBoxSubclassAssertion1() throws InterruptedException {
|
||||||
|
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
|
||||||
//create aBox and tBox, and SimpleReasoner to listen to them
|
//create aBox and SimpleReasoner to listen to them
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
// set up TBox
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -589,17 +520,14 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
aBox.add(c, OWL.sameAs, a);
|
aBox.add(c, OWL.sameAs, a);
|
||||||
|
|
||||||
// update TBox
|
// update TBox
|
||||||
classA.addSubClass(classB);
|
addSubclass(classA, classB);
|
||||||
|
|
||||||
// wait for SimpleReasonerTBoxListener thread to end
|
// wait for SimpleReasonerTBoxListener thread to end
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
classB.addSubClass(classC);
|
addSubclass(classB, classC);
|
||||||
classA.addSubClass(classC); // simulate what Pellet would infer, and
|
|
||||||
// thus what the SimpleReasonerTBoxListener
|
|
||||||
// would be notified of.
|
|
||||||
|
|
||||||
// wait for SimpleReasonerTBoxListener thread to end
|
// wait for SimpleReasonerTBoxListener thread to end
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
|
@ -620,10 +548,7 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
Assert.assertTrue(inf.contains(c, RDF.type, classA));
|
Assert.assertTrue(inf.contains(c, RDF.type, classA));
|
||||||
|
|
||||||
// update TBox
|
// update TBox
|
||||||
classA.removeSubClass(classB);
|
removeSubclass(classA, classB);
|
||||||
classA.removeSubClass(classC); // simulate what Pellet would infer, and
|
|
||||||
// thus what the SimpleReasonerTBoxListener
|
|
||||||
// would be notified of.
|
|
||||||
|
|
||||||
// wait for SimpleReasonerTBoxListener thread to end
|
// wait for SimpleReasonerTBoxListener thread to end
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
|
@ -644,7 +569,7 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
Assert.assertFalse(inf.contains(c, RDF.type, classA));
|
Assert.assertFalse(inf.contains(c, RDF.type, classA));
|
||||||
|
|
||||||
// update TBox
|
// update TBox
|
||||||
classB.removeSubClass(classC);
|
removeSubclass(classB, classC);
|
||||||
|
|
||||||
// wait for SimpleReasonerTBoxListener thread to end
|
// wait for SimpleReasonerTBoxListener thread to end
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
|
@ -672,25 +597,20 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
* individuals
|
* individuals
|
||||||
*/
|
*/
|
||||||
//@Test
|
//@Test
|
||||||
public void mostSpecificTypeTest1() throws InterruptedException {
|
public void mostSpecificTypeTest1() {
|
||||||
|
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/B", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/B", "class D");
|
||||||
|
OntClass classE = createClass(tBox, "http://test.vivo/B", "class E");
|
||||||
|
addSubclass(classA, classC);
|
||||||
|
addSubclass(classC, classD);
|
||||||
|
addSubclass(classC, classE);
|
||||||
|
|
||||||
// set up tbox. Pellet is reasoning; SimpleReasonerTBoxListener is not being used.
|
// SimpleReasonerTBoxListener is not being used.
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
OntClass classE = tBox.createClass("http://test.vivo/E");
|
|
||||||
classE.setLabel("class E", "en-US");
|
|
||||||
|
|
||||||
classA.addSubClass(classC);
|
|
||||||
classC.addSubClass(classD);
|
|
||||||
classC.addSubClass(classE);
|
|
||||||
|
|
||||||
// this will receive the abox inferences
|
// this will receive the abox inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -755,21 +675,11 @@ public class SimpleReasonerSameAsTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void recomputeABox1() throws InterruptedException {
|
public void recomputeABox1() throws InterruptedException {
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||||
|
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||||
OntProperty P = tBox.createObjectProperty("http://test.vivo/P");
|
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||||
P.setLabel("property P", "en-US");
|
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||||
|
|
||||||
OntProperty Q = tBox.createObjectProperty("http://test.vivo/Q");
|
|
||||||
Q.setLabel("property Q", "en-US");
|
|
||||||
|
|
||||||
OntProperty S = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
S.setLabel("property S", "en-US");
|
|
||||||
|
|
||||||
OntProperty T = tBox.createDatatypeProperty("http://test.vivo/");
|
|
||||||
T.setLabel("property T", "en-US");
|
|
||||||
|
|
||||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,232 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.reasoner;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.ObjectProperty;
|
||||||
|
import com.hp.hpl.jena.ontology.OntClass;
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
|
import com.hp.hpl.jena.ontology.OntProperty;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We're using a simple OntModel as the TBox in the SimpleReasoner tests, so we
|
||||||
|
* don't get tied to a particular TBox reasoner (like Pellet).
|
||||||
|
*
|
||||||
|
* But the SimpleReasoner expects certain elementary reasoning, so these methods
|
||||||
|
* impose that reasoning on the model.
|
||||||
|
*
|
||||||
|
* On the model: Thing is a class.
|
||||||
|
*
|
||||||
|
* On classes: Every class is equivalent to itself, a subclass of itself, and a
|
||||||
|
* subclass of Thing. Every class is a subclass of all its ancestors and a
|
||||||
|
* superclass of all its descendants. Every class has the same superclasses and
|
||||||
|
* subclasses as do all of its equivalent classes.
|
||||||
|
*
|
||||||
|
* On object properties: Every object property is equivalent to itself and a
|
||||||
|
* subproperty of itself. Every object property has the same inverses as do all
|
||||||
|
* of its equivalent properties.
|
||||||
|
*
|
||||||
|
* ----------------------
|
||||||
|
*
|
||||||
|
* It's a little silly to implement this as a parent class of the unit tests. It
|
||||||
|
* would have been nicer to find a way that is more object-oriented but still
|
||||||
|
* explicit in what "reasoning" is performed. This will do for now.
|
||||||
|
*/
|
||||||
|
public class SimpleReasonerTBoxHelper extends AbstractTestClass {
|
||||||
|
private static String URI_THING = "http://www.w3.org/2002/07/owl#Thing";
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// The model
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected OntModel createTBoxModel() {
|
||||||
|
OntModel tBox = ModelFactory
|
||||||
|
.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
||||||
|
createClass(tBox, URI_THING, "OWL Thing");
|
||||||
|
return tBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Classes
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected OntClass createClass(OntModel tBox, String uri, String label) {
|
||||||
|
OntClass s = tBox.createClass(uri);
|
||||||
|
s.setLabel(label, "en-US");
|
||||||
|
s.addEquivalentClass(s);
|
||||||
|
s.addSubClass(s);
|
||||||
|
thing(tBox).addSubClass(s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntClass thing(OntModel tBox) {
|
||||||
|
return tBox.getOntClass(URI_THING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure that you establish subclass relationships before setting
|
||||||
|
* equivalent classes.
|
||||||
|
*/
|
||||||
|
protected void setEquivalent(OntClass c1, OntClass c2) {
|
||||||
|
setEquivalentClasses(equivalences(c1), equivalences(c2));
|
||||||
|
setEquivalentClasses(equivalences(c2), equivalences(c1));
|
||||||
|
c1.addEquivalentClass(c2);
|
||||||
|
c2.addEquivalentClass(c1);
|
||||||
|
copySubClasses(c1, c2);
|
||||||
|
copySubClasses(c2, c1);
|
||||||
|
copySuperClasses(c1, c2);
|
||||||
|
copySuperClasses(c2, c1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEquivalentClasses(Set<OntClass> equivalences1,
|
||||||
|
Set<OntClass> equivalences2) {
|
||||||
|
for (OntClass c1 : equivalences1) {
|
||||||
|
for (OntClass c2 : equivalences2) {
|
||||||
|
c1.addEquivalentClass(c2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copySubClasses(OntClass c1, OntClass c2) {
|
||||||
|
for (OntClass sub : c1.listSubClasses().toList()) {
|
||||||
|
c2.addSubClass(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copySuperClasses(OntClass c1, OntClass c2) {
|
||||||
|
for (OntClass sup : c1.listSuperClasses().toList()) {
|
||||||
|
c2.addSuperClass(sup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<OntClass> equivalences(OntClass c1) {
|
||||||
|
return new HashSet<OntClass>(c1.listEquivalentClasses().toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSubclass(OntClass parent, OntClass child) {
|
||||||
|
addSubclass(equivalences(parent), equivalences(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSubclass(Set<OntClass> equivalentParents,
|
||||||
|
Set<OntClass> equivalentChildren) {
|
||||||
|
for (OntClass parent : equivalentParents) {
|
||||||
|
for (OntClass child : equivalentChildren) {
|
||||||
|
parent.addSubClass(child);
|
||||||
|
|
||||||
|
for (OntClass ancestor : parent.listSuperClasses().toList()) {
|
||||||
|
ancestor.addSubClass(child);
|
||||||
|
}
|
||||||
|
for (OntClass descendant : child.listSubClasses().toList()) {
|
||||||
|
parent.addSubClass(descendant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void removeSubclass(OntClass parent, OntClass child) {
|
||||||
|
removeSubclass(equivalences(parent), equivalences(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This has the potential for problems if we set this up:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* A -> B -> C
|
||||||
|
*
|
||||||
|
* explicit add A -> C
|
||||||
|
*
|
||||||
|
* remove A -> B
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* But why would we do that?
|
||||||
|
*/
|
||||||
|
private void removeSubclass(Set<OntClass> equivalentParents,
|
||||||
|
Set<OntClass> equivalentChildren) {
|
||||||
|
for (OntClass parent : equivalentParents) {
|
||||||
|
for (OntClass child : equivalentChildren) {
|
||||||
|
parent.removeSubClass(child);
|
||||||
|
|
||||||
|
for (OntClass ancestor : parent.listSuperClasses().toList()) {
|
||||||
|
ancestor.removeSubClass(child);
|
||||||
|
}
|
||||||
|
for (OntClass descendant : child.listSubClasses().toList()) {
|
||||||
|
parent.removeSubClass(descendant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Object properties
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
protected ObjectProperty createObjectProperty(OntModel tBox, String uri,
|
||||||
|
String label) {
|
||||||
|
ObjectProperty p = tBox.createObjectProperty(uri);
|
||||||
|
p.setLabel(label, "en-US");
|
||||||
|
p.addEquivalentProperty(p);
|
||||||
|
p.addSubProperty(p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setEquivalent(OntProperty p1, OntProperty p2) {
|
||||||
|
setEquivalentProperty(equivalences(p1), equivalences(p2));
|
||||||
|
setEquivalentProperty(equivalences(p2), equivalences(p1));
|
||||||
|
copyInverses(p1, p2);
|
||||||
|
copyInverses(p2, p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEquivalentProperty(Set<OntProperty> equivalences1,
|
||||||
|
Set<OntProperty> equivalences2) {
|
||||||
|
for (OntProperty p1 : equivalences1) {
|
||||||
|
for (OntProperty p2 : equivalences2) {
|
||||||
|
p1.addEquivalentProperty(p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyInverses(OntProperty p1, OntProperty p2) {
|
||||||
|
for (OntProperty inv : p1.listInverse().toList()) {
|
||||||
|
p2.addInverseOf(inv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setInverse(OntProperty p1, OntProperty p2) {
|
||||||
|
setInverse(equivalences(p1), equivalences(p2));
|
||||||
|
setInverse(equivalences(p2), equivalences(p1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInverse(Set<OntProperty> equivalences1,
|
||||||
|
Set<OntProperty> equivalences2) {
|
||||||
|
for (OntProperty p1 : equivalences1) {
|
||||||
|
for (OntProperty p2 : equivalences2) {
|
||||||
|
p1.addInverseOf(p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void removeInverse(OntProperty p1, OntProperty p2) {
|
||||||
|
removeInverse(equivalences(p1), equivalences(p2));
|
||||||
|
removeInverse(equivalences(p2), equivalences(p1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeInverse(Set<OntProperty> equivalences1,
|
||||||
|
Set<OntProperty> equivalences2) {
|
||||||
|
for (OntProperty p1 : equivalences1) {
|
||||||
|
for (OntProperty p2 : equivalences2) {
|
||||||
|
p1.removeInverseProperty(p2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<OntProperty> equivalences(OntProperty p) {
|
||||||
|
return new HashSet<OntProperty>(p.listEquivalentProperties().toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mindswap.pellet.jena.PelletReasonerFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
||||||
import com.hp.hpl.jena.ontology.OntClass;
|
import com.hp.hpl.jena.ontology.OntClass;
|
||||||
|
@ -21,11 +20,10 @@ import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
|
|
||||||
public class SimpleReasonerTest extends AbstractTestClass {
|
public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
||||||
|
|
||||||
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
||||||
long delay = 50;
|
long delay = 50;
|
||||||
|
@ -54,15 +52,9 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
public void addABoxTypeAssertion1( boolean sameAsEnabled ){
|
public void addABoxTypeAssertion1( boolean sameAsEnabled ){
|
||||||
|
|
||||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
classA.addSubClass(classB);
|
classA.addSubClass(classB);
|
||||||
|
|
||||||
// this is the model to receive inferences
|
// this is the model to receive inferences
|
||||||
|
@ -101,29 +93,17 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
public void addABoxTypeAssertion2(boolean enableSameAs){
|
public void addABoxTypeAssertion2(boolean enableSameAs){
|
||||||
|
|
||||||
// Create a Tbox with a simple class hierarchy. D and E are subclasses
|
// Create a Tbox with a simple class hierarchy. D and E are subclasses
|
||||||
// of C. B and C are subclasses of A. Pellet will compute TBox inferences.
|
// of C. B and C are subclasses of A.
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
classA.setLabel("class A", "en-US");
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||||
classB.setLabel("class B", "en-US");
|
addSubclass(classA, classB);
|
||||||
|
addSubclass(classA, classC);
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
addSubclass(classC, classD);
|
||||||
classC.setLabel("class C", "en-US");
|
addSubclass(classC, classE);
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
OntClass classE = tBox.createClass("http://test.vivo/E");
|
|
||||||
classE.setLabel("class E", "en-US");
|
|
||||||
|
|
||||||
classC.addSubClass(classD);
|
|
||||||
classC.addSubClass(classE);
|
|
||||||
|
|
||||||
classA.addSubClass(classB);
|
|
||||||
classA.addSubClass(classC);
|
|
||||||
|
|
||||||
// this is the model to receive inferences
|
// this is the model to receive inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -160,11 +140,16 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void addABoxTypeAssertion3(boolean enableSameAs) throws InterruptedException {
|
public void addABoxTypeAssertion3(boolean enableSameAs) throws InterruptedException {
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Add classes A, B and C to the TBox
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// A is equivalent to B
|
||||||
// Pellet will compute TBox inferences
|
// C is a subclass of A
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
addSubclass(classA, classC);
|
||||||
|
setEquivalent(classA, classB);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -175,22 +160,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes A, B and C to the TBox
|
|
||||||
// A is equivalent to B
|
|
||||||
// C is a subclass of A
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
classA.addEquivalentClass(classB);
|
|
||||||
classA.addSubClass(classC);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -223,11 +192,13 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void addABoxTypeAssertion4(boolean enableSameAs) throws InterruptedException {
|
public void addABoxTypeAssertion4(boolean enableSameAs) throws InterruptedException {
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Add classes A and B to the TBox
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// A is equivalent to B
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
setEquivalent(classA, classB);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -238,17 +209,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes A and B to the TBox
|
|
||||||
// A is equivalent to B
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
classA.addEquivalentClass(classB);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -278,11 +238,13 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void addABoxTypeAssertion5(boolean enableSameAs) throws InterruptedException {
|
public void addABoxTypeAssertion5(boolean enableSameAs) throws InterruptedException {
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Add classes classes A and B to the TBox
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// A is equivalent to B
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
setEquivalent(classA, classB);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -293,17 +255,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes classes A and B to the TBox
|
|
||||||
// A is equivalent to B
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
classA.addEquivalentClass(classB);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -326,11 +277,11 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeABoxTypeAssertion1Test()throws InterruptedException{
|
public void removeABoxTypeAssertion1Test() {
|
||||||
removeABoxTypeAssertion1(true);
|
removeABoxTypeAssertion1(true);
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void removeABoxTypeAssertion1NoSameAs()throws InterruptedException{
|
public void removeABoxTypeAssertion1NoSameAs() {
|
||||||
removeABoxTypeAssertion1(false);
|
removeABoxTypeAssertion1(false);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -344,21 +295,14 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
public void removeABoxTypeAssertion1(boolean enableSameAs){
|
public void removeABoxTypeAssertion1(boolean enableSameAs){
|
||||||
|
|
||||||
// Create a Tbox with a simple class hierarchy. C is a subclass of B
|
// Create a Tbox with a simple class hierarchy. C is a subclass of B
|
||||||
// and B is a subclass of A. Pellet will compute TBox inferences.
|
// and B is a subclass of A.
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
classA.setLabel("class A", "en-US");
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
addSubclass(classB, classC);
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
addSubclass(classA, classB);
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
classB.addSubClass(classC);
|
|
||||||
classA.addSubClass(classB);
|
|
||||||
|
|
||||||
// this is the model to receive inferences
|
// this is the model to receive inferences
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
@ -415,12 +359,15 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
* as a test of equivalentClass statements also.
|
* as a test of equivalentClass statements also.
|
||||||
*/
|
*/
|
||||||
public void addTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
public void addTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
||||||
|
// Create the TBox and add classes A, B, C and D
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Create ABox and Inference models and register
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
// Pellet will compute TBox inferences
|
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -431,27 +378,12 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes classes A, B, C and D to the TBox
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
// Add a statement that individual x is of type C to the ABox
|
// Add a statement that individual x is of type C to the ABox
|
||||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||||
aBox.add(ind_x, RDF.type, classC);
|
aBox.add(ind_x, RDF.type, classC);
|
||||||
|
|
||||||
// Add a statement that C is a subclass of A to the TBox
|
// Add a statement that C is a subclass of A to the TBox
|
||||||
|
addSubclass(classA, classC);
|
||||||
classA.addSubClass(classC);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -498,11 +430,17 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
*/
|
*/
|
||||||
public void addTBoxSubClassAssertion2(boolean enableSameAs) throws InterruptedException {
|
public void addTBoxSubClassAssertion2(boolean enableSameAs) throws InterruptedException {
|
||||||
|
|
||||||
// Create TBox, ABox and Inference models and register
|
// Create the TBox and add classes A, B, C and D.
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// D is a subclass of C.
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
|
addSubclass(classC, classD);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -513,23 +451,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes classes A, B, C and D to the TBox
|
|
||||||
// D is a subclass of C
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
classC.addSubClass(classD);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -539,7 +460,7 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
aBox.add(ind_x, RDF.type, classD);
|
aBox.add(ind_x, RDF.type, classD);
|
||||||
|
|
||||||
// Add a statement that C is a subclass of A to the TBox
|
// Add a statement that C is a subclass of A to the TBox
|
||||||
classA.addSubClass(classC);
|
addSubclass(classA, classC);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -569,11 +490,30 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
public void removeTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
||||||
// Create TBox, ABox and Inference models and register
|
// Create the TBox and add classes A, B, C, D, E, F, G and H.
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// B, C and D are subclasses of A.
|
||||||
// Pellet will compute TBox inferences
|
// E is a subclass of B.
|
||||||
|
// F and G are subclasses of C.
|
||||||
|
// H is a subclass of D.
|
||||||
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
|
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||||
|
OntClass classF = createClass(tBox, "http://test.vivo/F", "class F");
|
||||||
|
OntClass classG = createClass(tBox, "http://test.vivo/G", "class G");
|
||||||
|
OntClass classH = createClass(tBox, "http://test.vivo/H", "class H");
|
||||||
|
addSubclass(classA, classB);
|
||||||
|
addSubclass(classA, classC);
|
||||||
|
addSubclass(classA, classD);
|
||||||
|
addSubclass(classB, classE);
|
||||||
|
addSubclass(classC, classF);
|
||||||
|
addSubclass(classC, classG);
|
||||||
|
addSubclass(classD, classH);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -584,44 +524,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Add classes A, B, C, D, E, F, G and H to the TBox.
|
|
||||||
// B, C and D are subclasses of A.
|
|
||||||
// E is a subclass of B.
|
|
||||||
// F and G are subclasses of C.
|
|
||||||
// H is a subclass of D.
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
OntClass classE = tBox.createClass("http://test.vivo/E");
|
|
||||||
classE.setLabel("class E", "en-US");
|
|
||||||
|
|
||||||
OntClass classF = tBox.createClass("http://test.vivo/F");
|
|
||||||
classF.setLabel("class F", "en-US");
|
|
||||||
|
|
||||||
OntClass classG = tBox.createClass("http://test.vivo/G");
|
|
||||||
classG.setLabel("class G", "en-US");
|
|
||||||
|
|
||||||
OntClass classH = tBox.createClass("http://test.vivo/H");
|
|
||||||
classH.setLabel("class H", "en-US");
|
|
||||||
|
|
||||||
classA.addSubClass(classB);
|
|
||||||
classA.addSubClass(classC);
|
|
||||||
classA.addSubClass(classD);
|
|
||||||
classB.addSubClass(classE);
|
|
||||||
classC.addSubClass(classF);
|
|
||||||
classC.addSubClass(classG);
|
|
||||||
classD.addSubClass(classH);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -631,7 +533,7 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
aBox.add(ind_x, RDF.type, classE);
|
aBox.add(ind_x, RDF.type, classE);
|
||||||
|
|
||||||
// Remove the statement that B is a subclass of A from the TBox
|
// Remove the statement that B is a subclass of A from the TBox
|
||||||
classA.removeSubClass(classB);
|
removeSubclass(classA, classB);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -664,13 +566,13 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
simpleReasonerTBoxListener.setStopRequested();
|
simpleReasonerTBoxListener.setStopRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore(" needs PelletListener infrastructure which is not in this suite.")
|
@Ignore(" needs TBoxReasoner infrastructure which is not in this suite.")
|
||||||
@Test
|
@Test
|
||||||
public void bcdTest()throws InterruptedException{
|
public void bcdTest()throws InterruptedException{
|
||||||
bcd(true);
|
bcd(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore(" needs PelletListener infrastructure which is not in this suite.")
|
@Ignore(" needs TBoxReasoner infrastructure which is not in this suite.")
|
||||||
@Test
|
@Test
|
||||||
public void bcdNoSameAsTest()throws InterruptedException{
|
public void bcdNoSameAsTest()throws InterruptedException{
|
||||||
bcd(false);
|
bcd(false);
|
||||||
|
@ -682,17 +584,16 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
* inference graph.
|
* inference graph.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// this test would need PelletListener infrastructure, which we're not
|
// this test would need TBoxReasoner infrastructure, which we're not
|
||||||
// testing in this suite. The reason it doesn't work as it is because
|
// testing in this suite. The reason it doesn't work as it is because
|
||||||
// the SimpleReasonerTBoxListener is not listening to the tBox inference
|
// the SimpleReasonerTBoxListener is not listening to the tBox inference
|
||||||
// model as Pellet is updating it. I could simulate it by adding to the
|
// model as the TBoxReasoner is updating it. I could simulate it by adding to the
|
||||||
// tBox assertions what we can count on Pellet to infer.
|
// tBox assertions what we can count on the TBoxReasoner to infer.
|
||||||
public void bcd(boolean enableSameAs) throws InterruptedException {
|
public void bcd(boolean enableSameAs) throws InterruptedException {
|
||||||
// Create TBox, ABox and Inference models and register
|
OntModel tBox = createTBoxModel();
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
|
||||||
// Pellet will compute TBox inferences
|
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -704,18 +605,11 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
|
|
||||||
// Add classes LivingThing, Flora, Brassica to the TBox
|
// Add classes LivingThing, Flora, Brassica to the TBox
|
||||||
// Brassica is a subClass of Flora and Flora is a subclass of Brassica
|
// Brassica is a subClass of Flora and Flora is a subclass of Brassica
|
||||||
|
OntClass LivingThing = createClass(tBox, "http://test.vivo/LivingThing", "Living Thing");
|
||||||
OntClass LivingThing = tBox.createClass("http://test.vivo/LivingThing");
|
OntClass Flora = createClass(tBox, "http://test.vivo/Flora", "Flora");
|
||||||
LivingThing.setLabel("Living Thing", "en-US");
|
OntClass Brassica = createClass(tBox, "http://test.vivo/Brassica", "Brassica");
|
||||||
|
addSubclass(LivingThing, Flora);
|
||||||
OntClass Flora = tBox.createClass("http://test.vivo/Flora");
|
addSubclass(Flora, Brassica);
|
||||||
Flora.setLabel("Flora", "en-US");
|
|
||||||
|
|
||||||
OntClass Brassica = tBox.createClass("http://test.vivo/Brassica");
|
|
||||||
Brassica.setLabel("Brassica", "en-US");
|
|
||||||
|
|
||||||
LivingThing.addSubClass(Flora);
|
|
||||||
Flora.addSubClass(Brassica);
|
|
||||||
|
|
||||||
tBox.rebind();
|
tBox.rebind();
|
||||||
tBox.prepare();
|
tBox.prepare();
|
||||||
|
@ -761,11 +655,23 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
* to an added/removed ABox type assertion.
|
* to an added/removed ABox type assertion.
|
||||||
*/
|
*/
|
||||||
public void mstTest1(boolean enableSameAs) throws InterruptedException {
|
public void mstTest1(boolean enableSameAs) throws InterruptedException {
|
||||||
// Create TBox, ABox and Inference models and register
|
// Set up the Tbox with a class hierarchy. C is a subclass of A
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// and Y. D and E are subclasses of C. B is a subclass of D.
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
|
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||||
|
OntClass classY = createClass(tBox, "http://test.vivo/Y", "class Y");
|
||||||
|
addSubclass(classA, classC);
|
||||||
|
addSubclass(classY, classC);
|
||||||
|
addSubclass(classC, classD);
|
||||||
|
addSubclass(classC, classE);
|
||||||
|
addSubclass(classD, classB);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -776,38 +682,8 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Set up the Tbox with a class hierarchy. C is a subclass of A
|
|
||||||
// and Y. D and E are subclasses C. B is a subclass of D.
|
|
||||||
// Pellet will compute TBox inferences.
|
|
||||||
|
|
||||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
OntClass classE = tBox.createClass("http://test.vivo/E");
|
|
||||||
classE.setLabel("class E", "en-US");
|
|
||||||
|
|
||||||
OntClass classY = tBox.createClass("http://test.vivo/Y");
|
|
||||||
classE.setLabel("class Y", "en-US");
|
|
||||||
|
|
||||||
classY.addSubClass(classC);
|
|
||||||
classA.addSubClass(classC);
|
|
||||||
|
|
||||||
classC.addSubClass(classD);
|
|
||||||
classC.addSubClass(classE);
|
|
||||||
|
|
||||||
classD.addSubClass(classB);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -848,11 +724,17 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
* to an added ABox type assertion.
|
* to an added ABox type assertion.
|
||||||
*/
|
*/
|
||||||
public void mstTest2(boolean enableSameAs) throws InterruptedException {
|
public void mstTest2(boolean enableSameAs) throws InterruptedException {
|
||||||
// Create TBox, ABox and Inference models and register
|
// Set up the Tbox with a class hierarchy. A, B, and C are all equivalent.
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
// This implies that they are all subclasses of each other.
|
||||||
// Pellet will compute TBox inferences
|
OntModel tBox = createTBoxModel();
|
||||||
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
setEquivalent(classA, classB);
|
||||||
|
setEquivalent(classB, classC);
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -863,25 +745,8 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||||
tBox.register(simpleReasonerTBoxListener);
|
tBox.register(simpleReasonerTBoxListener);
|
||||||
|
|
||||||
// Set up the Tbox with a class hierarchy. B is a subclass of A,
|
|
||||||
// C is a subclass of B, and A is a subclass of C.
|
|
||||||
// Pellet should infer these three classes to be equivalent.
|
|
||||||
|
|
||||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
classA.addSubClass(classB);
|
|
||||||
classB.addSubClass(classC);
|
|
||||||
classC.addSubClass(classA);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -911,11 +776,18 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
* to an added/removed TBox assertions.
|
* to an added/removed TBox assertions.
|
||||||
*/
|
*/
|
||||||
public void mstTest3(boolean enableSameAs) throws InterruptedException {
|
public void mstTest3(boolean enableSameAs) throws InterruptedException {
|
||||||
// Create TBox, ABox and Inference models and register
|
// Set up the Tbox with classes A, B, C, D, E, F and G
|
||||||
// the ABox reasoner listeners with the ABox and TBox
|
OntModel tBox = createTBoxModel();
|
||||||
// Pellet will compute TBox inferences
|
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||||
|
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||||
|
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||||
|
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||||
|
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||||
|
OntClass classF = createClass(tBox, "http://test.vivo/F", "class F");
|
||||||
|
OntClass classG = createClass(tBox, "http://test.vivo/G", "class G");
|
||||||
|
|
||||||
OntModel tBox = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
|
// Create ABox and Inference models and register
|
||||||
|
// the ABox reasoner listeners with the ABox and TBox
|
||||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model inf = ModelFactory.createDefaultModel();
|
Model inf = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
@ -929,30 +801,6 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
OntClass OWL_THING = tBox.createClass(OWL.Thing.getURI());
|
OntClass OWL_THING = tBox.createClass(OWL.Thing.getURI());
|
||||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||||
|
|
||||||
// Set up the Tbox with classes A, B, C, D,
|
|
||||||
// E, F and G
|
|
||||||
|
|
||||||
OntClass classA = tBox.createClass("http://test.vivo/A");
|
|
||||||
classA.setLabel("class A", "en-US");
|
|
||||||
|
|
||||||
OntClass classB = tBox.createClass("http://test.vivo/B");
|
|
||||||
classB.setLabel("class B", "en-US");
|
|
||||||
|
|
||||||
OntClass classC = tBox.createClass("http://test.vivo/C");
|
|
||||||
classC.setLabel("class C", "en-US");
|
|
||||||
|
|
||||||
OntClass classD = tBox.createClass("http://test.vivo/D");
|
|
||||||
classD.setLabel("class D", "en-US");
|
|
||||||
|
|
||||||
OntClass classE = tBox.createClass("http://test.vivo/E");
|
|
||||||
classE.setLabel("class E", "en-US");
|
|
||||||
|
|
||||||
OntClass classF = tBox.createClass("http://test.vivo/F");
|
|
||||||
classF.setLabel("class F", "en-US");
|
|
||||||
|
|
||||||
OntClass classG = tBox.createClass("http://test.vivo/G");
|
|
||||||
classE.setLabel("class G", "en-US");
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
}
|
}
|
||||||
|
@ -976,16 +824,12 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classF.getURI())));
|
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classF.getURI())));
|
||||||
|
|
||||||
// Set up a class hierarchy.
|
// Set up a class hierarchy.
|
||||||
// Pellet will compute TBox inferences.
|
addSubclass(classA, classB);
|
||||||
|
addSubclass(classA, classC);
|
||||||
classA.addSubClass(classB);
|
addSubclass(classA, classD);
|
||||||
classA.addSubClass(classC);
|
addSubclass(classC, classE);
|
||||||
classA.addSubClass(classD);
|
addSubclass(classD, classF);
|
||||||
|
addSubclass(classD, classG);
|
||||||
classC.addSubClass(classE);
|
|
||||||
|
|
||||||
classD.addSubClass(classF);
|
|
||||||
classD.addSubClass(classG);
|
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
@ -996,7 +840,7 @@ public class SimpleReasonerTest extends AbstractTestClass {
|
||||||
|
|
||||||
// If F is removed as a subclass of D, then D should once again be a most specific type
|
// If F is removed as a subclass of D, then D should once again be a most specific type
|
||||||
// for y.
|
// for y.
|
||||||
classD.removeSubClass(classF);
|
removeSubclass(classD, classF);
|
||||||
|
|
||||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(delay);
|
||||||
|
|
|
@ -174,17 +174,5 @@ PREFIX <%=prefixText%>: <<%=urlText%>><%}}%>
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
</select> <c:choose>
|
</select>
|
||||||
<c:when test="${paramValues['reasoning'] != null}">
|
<input id="submit" type="submit" value="Execute CONSTRUCT" />
|
||||||
<c:forEach var="paramValue" items="${paramValues['reasoning']}">
|
|
||||||
<c:if test="${paramValue eq 'pellet'}">
|
|
||||||
<p><input type="checkbox" name="reasoning" value="pellet"
|
|
||||||
checked="checked" /> include pellet reasoning</p>
|
|
||||||
</c:if>
|
|
||||||
</c:forEach>
|
|
||||||
</c:when>
|
|
||||||
<c:otherwise>
|
|
||||||
<p><input type="checkbox" name="reasoning" value="pellet" />
|
|
||||||
include Pellet OWL-DL reasoning</p>
|
|
||||||
</c:otherwise>
|
|
||||||
</c:choose> <input id="submit" type="submit" value="Execute CONSTRUCT" />
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue