/** * Construct a new ontology model from the given specification. The base model is * produced using the baseModelMaker. */ public OntModelImpl( OntModelSpec spec ) { this( spec, spec.createBaseModel(), true ); }
/** * <p>Create one model spec as a copy of another. This is useful when what is required is similar to * an existing spec, but with some changes. <strong>Note:</strong> this is only a shallow copy, so the * structured objects (reasoners, document managers, etc) are not themselves copied. Thus, even after * calling this copy constructor, making a change to the document manager in the copy specification * will also affect the one that the copy was made from. The correct idiom is to replace the object * before side-effecting it, e.g: * <code><pre> * OntModelSpec newSpec = new OntModelSpec( existingSpec ); * newSpec.setDocumentManager( new OntDocumentManager() ); * newSpec.getDocumentManager().setMetaDataSearchPath( "..." ); * </pre></code> * @param spec */ public OntModelSpec( OntModelSpec spec ) { this( spec.getBaseModelMaker(), spec.getImportModelMaker(), spec.getDocumentManager(), spec.getReasonerFactory(), spec.getLanguage() ); }
private boolean same( OntModelSpec other ) { return getLanguage().equals( other.getLanguage() ) && sameReasonerFactory( other ) && getDocumentManager().equals( other.getDocumentManager() ) && getImportModelGetter().equals( other.getImportModelGetter() ) ; }
@Override public Object open( Assembler a, Resource root, Mode irrelevant ) { checkType( root, JA.OntModelSpec ); OntModelSpec spec = new OntModelSpec( getDefault( root ) ); OntDocumentManager dm = getDocumentManager( a, root ); ReasonerFactory rf = getReasonerFactory( a, root ); String lang = getLanguage( a, root ); ModelGetter source = getModelSource( a, root ); if (dm != null) spec.setDocumentManager( dm ); if (rf != null) spec.setReasonerFactory( rf ); if (lang != null) spec.setLanguage( lang ); if (source != null) spec.setImportModelGetter( source ); return spec; }
if (_spec.getDocumentManager() != this) { _spec = new OntModelSpec( spec ); _spec.setDocumentManager( this );
public OntologyHandler() { OntDocumentManager mgr = new OntDocumentManager(); mgr.setProcessImports(false); OntModelSpec s = new OntModelSpec( OntModelSpec.OWL_MEM ); s.setDocumentManager( mgr ); ontModel = ModelFactory.createOntologyModel(s); ontModel.setStrictMode(false); }
/** * Construct a new ontology model specification from the supplied components. * @param baseModelName the name of the model in the baseModelMaker * @param baseMaker the model-maker to use for the base model * @param importsMaker the model-maker to use for imported models * @param docMgr the document manager (null for the default manager) * @param rFactory the reasoner (null for no reasoner) * @param languageURI the ontology language URI (must not be null) */ public OntModelSpec( String baseModelName, ModelMaker baseMaker, ModelMaker importsMaker, OntDocumentManager docMgr, ReasonerFactory rFactory, String languageURI ) { // super( baseMaker ); this.maker = baseMaker; m_baseModelName = baseModelName; m_importsMaker = importsMaker == null ? ModelFactory.createMemModelMaker() : importsMaker; setDocumentManager( docMgr ); setReasonerFactory( rFactory ); if (languageURI == null) { throw new IllegalArgumentException( "Cannot create OntModelSpec with a null ontology language" ); } setLanguage( languageURI ); }
/** * <p> * Answer a new ontology model which will process in-memory models of * ontologies expressed the default ontology language (OWL). * The default document manager * will be used to load the ontology's included documents. * </p> * * @param spec An ontology model specification that defines the language and reasoner to use * @param maker A model maker that is used to get the initial store for the ontology (unless * the base model is given), * and create addtional stores for the models in the imports closure * @param base The base model, which contains the contents of the ontology to be processed * @return A new ontology model * @see OntModelSpec */ public static OntModel createOntologyModel( OntModelSpec spec, ModelMaker maker, Model base ) { OntModelSpec _spec = new OntModelSpec( spec ); _spec.setImportModelMaker( maker ); return createOntologyModel( _spec, base ); }
OntModelSpec s = new OntModelSpec( OntModelSpec.OWL_MEM ); this.model = ModelFactory.createOntologyModel( s ); this.model.read(in, "http://myevaluation.com#");
modelSpec.setDocumentManager(docManager);
/** * @param spec * @param importURI * @return Model */ private Model fetchLoadedImportModel( OntModelSpec spec, String importURI ) { // workaround - default model maker can apparently create models that are closed // TODO: this really suggests a bug in ModelMaker, kers to investigate ModelMaker maker = spec.getImportModelMaker(); if (maker.hasModel( importURI )) { Model m = maker.getModel( importURI ); if (!m.isClosed()) { return m; } else { // we don't want to hang on to closed models maker.removeModel( importURI ); } } // otherwise, we use the model maker to get the model anew Model m = spec.getImportModelGetter() .getModel( importURI, new ModelReader() { @Override public Model readModel( Model toRead, String URL ) { read( toRead, URL, true ); return toRead; } } ); return m; }
/** * <p> * Answer the model maker associated with this model (used for constructing the * constituent models of the imports closure). * </p> * * @return The local graph factory */ @Override public ModelMaker getImportModelMaker() { return m_spec.getImportModelMaker(); }
/** * <p> * Answer a reference to the document manager that this model is using to manage * ontology <-> mappings, and to load the imports closure. <strong>Note</strong> * the default ontology model {@linkplain OntModelSpec specifications} each have * a contained default document manager. Changing the document managers specified by * these default specification may (in fact, probably will) * affect other models built with the same specification * policy. This may or may not be as desired by the programmer! * </p> * @return A reference to this model's document manager, obtained from the specification object */ @Override public OntDocumentManager getDocumentManager() { return m_spec.getDocumentManager(); }
/** Answer the OntModelSpec described using the Jena Assembler vocabulary properties of the single resource in <code>model</code> of type JA:OntModelSpec. */ public static OntModelSpec assemble( Model model ) { return assemble( AssemblerHelp.singleRoot( model, JA.OntModelSpec ) ); }
/** * <p> * Answer a new ontology model which will process in-memory models of * ontologies in the given language. * The default document manager * will be used to load the ontology's included documents. * </p> * * @param languageURI The URI specifying the ontology language we want to process * @return A new ontology model * @see OntModelSpec#getDefaultSpec */ public static OntModel createOntologyModel( String languageURI ) { return createOntologyModel( OntModelSpec.getDefaultSpec( languageURI ), null ); }
/** Answer the supplied model, unless it's null, in which case answer a new model constructed as per spec. */ private static Model makeBaseModel( OntModelSpec spec, Model model ) { return model == null ? spec.createBaseModel() : model; }