001: /*
002: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: JenaModelSpec.java,v 1.8 2008/01/24 16:00:17 chris-dollin Exp $
005: */
006:
007: package com.hp.hpl.jena.vocabulary;
008:
009: import com.hp.hpl.jena.graph.*;
010: import com.hp.hpl.jena.rdf.model.*;
011: import com.hp.hpl.jena.shared.*;
012: import com.hp.hpl.jena.util.FileManager;
013:
014: /**
015: The Jena Model Specification vocabulary, schema, and some conversion methods.
016: See the modelspec and modelspec-details HOWTOs for discussion on how these
017: fit into the ModelSpec design and implementation.
018:
019: TODO ensure these have explicit tests [they were developed implicitly from the
020: ModelSpec tests].
021:
022: @deprecated Use the ReasonerVocabulary equivalents instead; if there
023: is no such equivalent, then you should be using the corresponding
024: JenaAssembler properties.
025:
026: @author kers
027: */
028: public class JenaModelSpec {
029: /**
030: The base URI for all the JenaModelSpec vocabulary items.
031: */
032: public static final String baseURI = "http://jena.hpl.hp.com/2003/08/jms#";
033:
034: /**
035: Answer the base URI for the JenaModelSpec vocabulary items.
036: */
037: public static String getURI() {
038: return baseURI;
039: }
040:
041: /**
042: The property of a ModelSpec that specifies the URI(s) from which it is
043: to be loaded when it has been created.
044: */
045: public static final Property loadWith = property("loadWith");
046:
047: /**
048: The property of an OntModelSpec that gives the language URI string.
049: */
050: public static final Property ontLanguage = property("ontLanguage");
051:
052: /**
053: The property of an OntModelSpec that gives the document manager resource.
054: */
055: public static final Property docManager = property("docManager");
056:
057: /**
058: The property of an RDBModelSpec that describes the connection
059: */
060: public static final Property hasConnection = property("hasConnection");
061:
062: /**
063: The property of an OntModelSpec that gives the MakerSpec used when
064: manufacturing models for imports.
065: */
066: public static final Property importMaker = property("importMaker");
067:
068: /**
069: The property of an InfModelSpec that specifies the ReasonerSpec to use.
070: */
071: public static final Property reasonsWith = property("reasonsWith");
072:
073: /**
074: The property of a reasoner spec that specifies a rule-set URL.
075: */
076: public static final Property ruleSetURL = property("ruleSetURL");
077:
078: /**
079: The property of a reasoner spec that specifies in-line rule-sets.
080: */
081: public static final Property ruleSet = property("ruleSet");
082:
083: /**
084: The property of a ModelSpec that specifies the model name.
085: */
086: public static final Property modelName = property("modelName");
087:
088: /**
089: The property of a reasoner spec that specifies a schema to load
090: */
091: public static final Property schemaURL = property("schemaURL");
092:
093: /**
094: The property of a RuleSet that specifies a rule.
095: */
096: public static final Property hasRule = property("hasRule");
097:
098: /**
099: The property of a document manager that gives its policy path string.
100: */
101: public static final Property policyPath = property("policyPath");
102:
103: /**
104: The property of an RDBMakerSpec that gives the string to use for the user name
105: when making the connection.
106: */
107: public static final Property dbUser = property("dbUser");
108:
109: /**
110: The property of an RDBMakerSpec that gives the string to use for the password
111: when making the connection.
112: */
113: public static final Property dbPassword = property("dbPassword");
114:
115: /**
116: The property of an RDBMakerSpec that gives the string to use for the database URL
117: when making the connection.
118: */
119: public static final Property dbURL = property("dbURL");
120:
121: /**
122: The property of an RDBMakerSpec that gives the string to use for the database
123: type when making the connection.
124: */
125: public static final Property dbType = property("dbType");
126:
127: /**
128: The property of an RDBMakerSpec that gives the string to use for class to load
129: [if any] when making the connection.
130: */
131: public static final Property dbClass = property("dbClass");
132:
133: /**
134: The property of a ModelSpec that specifies the resource which describes the maker.
135: */
136: public static final Property maker = property("maker");
137:
138: /**
139: The property of a MakerSpec that gives the reification mode for all its models.
140: */
141: public static final Property reificationMode = property("reificationMode");
142:
143: /**
144: The property of a ReasonerSpec that gives the resource who's URI is that of
145: the reasoner to use.
146: */
147: public static final Property reasoner = property("reasoner");
148:
149: /**
150: The property of a FileMakerSpec that gives the fileBase [root directory] of the
151: FileModelMaker.
152: */
153: public static final Property fileBase = property("fileBase");
154:
155: /**
156: The property of some subclass of jms:ModelSpec that specifies the name of the
157: Java class that implements that ModelSpec.
158: */
159: public static final Property typeCreatedBy = property("typeCreatedBy");
160:
161: /**
162: The class of MakerSpec resources.
163: */
164: public static final Resource MakerSpec = resource("MakerSpec");
165:
166: /**
167: The class of FileMakerSpec resources [subclass of MakerSpec].
168: */
169: public static final Resource FileMakerSpec = resource("FileMakerSpec");
170:
171: /**
172: The class of MemMakerSpec resources [subclass of MakerSpec].
173: */
174: public static final Resource MemMakerSpec = resource("MemMakerSpec");
175:
176: /**
177: The class of RDBMakerSpec resources [subclass of MakerSpec].
178: */
179: public static final Resource RDBMakerSpec = resource("RDBMakerSpec");
180:
181: /**
182: The class of ModelSpec resources.
183: */
184: public static final Resource ModelSpec = resource("ModelSpec");
185:
186: /**
187: DefaultModelSpec, a dynamic default ModelSpec
188: */
189: public static final Resource DefaultModelSpec = resource("DefaultModelSpec");
190:
191: /**
192: The class of PlainModelSpec resources [subclass of ModelSpec].
193: */
194: public static final Resource PlainModelSpec = resource("PlainModelSpec");
195:
196: /**
197: The class of FileModel specifications.
198: */
199: public static final Resource FileModelSpec = resource("FileModelSpec");
200:
201: /**
202: The class of InfModelSpec resources [subclass of ModelSpec].
203: */
204: public static final Resource InfModelSpec = resource("InfModelSpec");
205:
206: /**
207: The class of OntModelSpec resources [subclass of InfModelSpec].
208: */
209: public static final Resource OntModelSpec = resource("OntModelSpec");
210:
211: /**
212: The class of RDBModelSpec resources [subclass of PlainModelSpec]
213: */
214: public static final Resource RDBModelSpec = resource("RDBModelSpec");
215:
216: /**
217: The resource representing reification mode Standard.
218: */
219: public static final Resource rsStandard = resource("rsStandard");
220:
221: /**
222: The resource representing reification mode Minimal.
223: */
224: public static final Resource rsMinimal = resource("rsMinimal");
225:
226: /**
227: The resource representing reification mode Convenient.
228: */
229: public static final Resource rsConvenient = resource("rsConvenient");
230:
231: /**
232: The JenaModelSpec schema; accessed by <code>getSchema()</code>.
233: */
234: static protected Model schema = null;
235:
236: /**
237: Answer the JenaModelSpec schema encoded into a model. This defines the subclass
238: hierarchy and the essential domains of the properties. ["Essential"
239: means "relied on by the ModelSpec engines".] The schema is not loaded
240: until its first use.
241:
242: TODO make this model immutable once created.
243: */
244: public static Model getSchema() {
245: if (schema == null)
246: schema = ModelFactory.createRDFSModel(FileManager.get()
247: .loadModel("vocabularies/jena-model-spec.n3"));
248: return schema;
249: }
250:
251: /**
252: Utility: answer a resource in the jms namespace with the given local name.
253: */
254: protected static Resource resource(String ln) {
255: return ResourceFactory.createResource(baseURI + ln);
256: }
257:
258: /**
259: Utility: answer a property in the jms namespave with the given local name.
260: */
261: protected static Property property(String ln) {
262: return ResourceFactory.createProperty(baseURI + ln);
263: }
264:
265: /**
266: Answer the Node which corresponds to the supplied reification style. [Node,
267: not resource, purely because the use happens in BaseGraphMaker, ie at the
268: Graph level.]
269:
270: @param style the reification style for which the JenaModelSpec representation is required
271: @return the Node version of the appropriate JenaModelSpec.rs[name] vocabulary item
272: */
273: public static Node styleAsJMS(ReificationStyle style) {
274: if (style == ReificationStyle.Minimal)
275: return JenaModelSpec.rsMinimal.asNode();
276: if (style == ReificationStyle.Convenient)
277: return JenaModelSpec.rsConvenient.asNode();
278: if (style == ReificationStyle.Standard)
279: return JenaModelSpec.rsStandard.asNode();
280: return null;
281: }
282:
283: /**
284: Answer the Reifier.ReificationStyle value named by the argument, which should be a
285: JenaModelSpec.rs[something] value
286:
287: @param style the JenaModelSpec name of the reifier style
288: @return the actual Reifier.ReificationStyle value
289: */
290: public static ReificationStyle findStyle(RDFNode style) {
291: return findStyle(style.asNode());
292: }
293:
294: /**
295: Answer the Reifier.ReificationStyle value named by the argument, which should be a
296: JenaModelSpec.rs[something] Node
297:
298: @param style the JenaModelSpec name of the reifier style
299: @return the actual Reifier.ReificationStyle value
300: */
301: public static ReificationStyle findStyle(Node style) {
302: if (style.equals(JenaModelSpec.rsStandard.asNode()))
303: return ReificationStyle.Standard;
304: if (style.equals(JenaModelSpec.rsMinimal.asNode()))
305: return ReificationStyle.Minimal;
306: if (style.equals(JenaModelSpec.rsConvenient.asNode()))
307: return ReificationStyle.Convenient;
308: return null;
309: }
310: }
311:
312: /*
313: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
314: All rights reserved.
315:
316: Redistribution and use in source and binary forms, with or without
317: modification, are permitted provided that the following conditions
318: are met:
319:
320: 1. Redistributions of source code must retain the above copyright
321: notice, this list of conditions and the following disclaimer.
322:
323: 2. Redistributions in binary form must reproduce the above copyright
324: notice, this list of conditions and the following disclaimer in the
325: documentation and/or other materials provided with the distribution.
326:
327: 3. The name of the author may not be used to endorse or promote products
328: derived from this software without specific prior written permission.
329:
330: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
331: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
332: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
333: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
334: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
335: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
336: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
337: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
338: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
339: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
340: */
|