001: /******************************************************************
002: * File: OWLBRuleReasonerFactory.java
003: * Created by: Dave Reynolds
004: * Created on: 12-May-2003
005: *
006: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007: * [See end of file]
008: * $Id: OWLFBRuleReasonerFactory.java,v 1.17 2008/01/02 12:07:47 andy_seaborne Exp $
009: *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys;
010:
011: import com.hp.hpl.jena.reasoner.*;
012: import com.hp.hpl.jena.rdf.model.*;
013: import com.hp.hpl.jena.vocabulary.*;
014:
015: /**
016: * Factory class for creating blank instances of the OWL Reasoner.
017: * <p>
018: * The reasoner can be configured using three properties (set as
019: * properties of the base reasonder URI in a configuration model). These are:
020: * <ul>
021: * <li><b>derivationLogging</b> - if set to true this causes all derivations to
022: * be recorded in an internal data structure for replay through the {@link com.hp.hpl.jena.reasoner.InfGraph#getDerivation getDerivation}
023: * method. </li>
024: * <li><b>traceOn</b> - if set to true this causes all rule firings and deduced triples to be
025: * written out to the Log at INFO level.</li>
026: * <li><b>ruleThreshold</b> - which limits the number of rules that can be fired on a single
027: * data processing stage to the given number (useful to limit infinite runaways). </li>
028: * </ul>
029: *
030: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
031: * @version $Revision: 1.17 $ on $Date: 2008/01/02 12:07:47 $
032: */
033: public class OWLFBRuleReasonerFactory implements ReasonerFactory {
034:
035: /** Single global instance of this factory */
036: private static ReasonerFactory theInstance = new OWLFBRuleReasonerFactory();
037:
038: /** Static URI for this reasoner type */
039: public static final String URI = "http://jena.hpl.hp.com/2003/OWLFBRuleReasoner";
040:
041: /** Cache of the capabilities description */
042: protected Model capabilities;
043:
044: /**
045: * Return the single global instance of this factory
046: */
047: public static ReasonerFactory theInstance() {
048: return theInstance;
049: }
050:
051: /**
052: * Constructor method that builds an instance of the associated Reasoner
053: * @param configuration a set of arbitrary configuration information to be
054: * passed the reasoner encoded within an RDF graph
055: */
056: public Reasoner create(Resource configuration) {
057: OWLFBRuleReasoner reasoner = new OWLFBRuleReasoner(this );
058: if (configuration != null) {
059: Boolean doLog = Util.checkBinaryPredicate(
060: ReasonerVocabulary.PROPderivationLogging,
061: configuration);
062: if (doLog != null) {
063: reasoner.setDerivationLogging(doLog.booleanValue());
064: }
065: Boolean doTrace = Util.checkBinaryPredicate(
066: ReasonerVocabulary.PROPtraceOn, configuration);
067: if (doTrace != null) {
068: reasoner.setTraceOn(doTrace.booleanValue());
069: }
070: }
071: return reasoner;
072: }
073:
074: /**
075: * Return a description of the capabilities of this reasoner encoded in
076: * RDF. This method is normally called by the ReasonerRegistry which caches
077: * the resulting information so dynamically creating here is not really an overhead.
078: */
079: public Model getCapabilities() {
080: if (capabilities == null) {
081: capabilities = ModelFactory.createDefaultModel();
082: Resource base = capabilities.createResource(getURI());
083: base
084: .addProperty(ReasonerVocabulary.nameP,
085: "OWL BRule Reasoner")
086: .addProperty(
087: ReasonerVocabulary.descriptionP,
088: "Experimental OWL reasoner.\n"
089: + "Can separate tbox and abox data if desired to reuse tbox caching or mix them.")
090: .addProperty(ReasonerVocabulary.supportsP,
091: RDFS.subClassOf).addProperty(
092: ReasonerVocabulary.supportsP,
093: RDFS.subPropertyOf).addProperty(
094: ReasonerVocabulary.supportsP, RDFS.member)
095: .addProperty(ReasonerVocabulary.supportsP,
096: RDFS.range).addProperty(
097: ReasonerVocabulary.supportsP, RDFS.domain)
098: // TODO - add OWL elements supported
099: .addProperty(ReasonerVocabulary.supportsP,
100: ReasonerVocabulary.individualAsThingP)
101: .addProperty(ReasonerVocabulary.supportsP,
102: OWL.ObjectProperty).addProperty(
103: ReasonerVocabulary.supportsP,
104: OWL.DatatypeProperty).addProperty(
105: ReasonerVocabulary.supportsP,
106: OWL.FunctionalProperty).addProperty(
107: ReasonerVocabulary.supportsP,
108: OWL.SymmetricProperty).addProperty(
109: ReasonerVocabulary.supportsP,
110: OWL.TransitiveProperty).addProperty(
111: ReasonerVocabulary.supportsP,
112: OWL.InverseFunctionalProperty)
113:
114: .addProperty(ReasonerVocabulary.supportsP,
115: OWL.hasValue).addProperty(
116: ReasonerVocabulary.supportsP,
117: OWL.intersectionOf).addProperty(
118: ReasonerVocabulary.supportsP, OWL.unionOf) // Only partial
119: .addProperty(ReasonerVocabulary.supportsP,
120: OWL.minCardinality) // Only partial
121: .addProperty(ReasonerVocabulary.supportsP,
122: OWL.maxCardinality) // Only partial
123: .addProperty(ReasonerVocabulary.supportsP,
124: OWL.cardinality) // Only partial
125: .addProperty(ReasonerVocabulary.supportsP,
126: OWL.someValuesFrom) // Only partial
127: .addProperty(ReasonerVocabulary.supportsP,
128: OWL.allValuesFrom) // Only partial
129: .addProperty(ReasonerVocabulary.supportsP,
130: OWL.sameAs).addProperty(
131: ReasonerVocabulary.supportsP,
132: OWL.differentFrom).addProperty(
133: ReasonerVocabulary.supportsP,
134: OWL.disjointWith)
135:
136: .addProperty(ReasonerVocabulary.versionP, "0.1");
137: }
138: return capabilities;
139: }
140:
141: /**
142: * Return the URI labelling this type of reasoner
143: */
144: public String getURI() {
145: return URI;
146: }
147:
148: }
149:
150: /*
151: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
152: All rights reserved.
153:
154: Redistribution and use in source and binary forms, with or without
155: modification, are permitted provided that the following conditions
156: are met:
157:
158: 1. Redistributions of source code must retain the above copyright
159: notice, this list of conditions and the following disclaimer.
160:
161: 2. Redistributions in binary form must reproduce the above copyright
162: notice, this list of conditions and the following disclaimer in the
163: documentation and/or other materials provided with the distribution.
164:
165: 3. The name of the author may not be used to endorse or promote products
166: derived from this software without specific prior written permission.
167:
168: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
169: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
170: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
171: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
172: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
173: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
174: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
175: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
176: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
177: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
178: */
|