public TDBStoreManager(String path) {
    this.path = path;
    accessor = DatasetAccessorFactory.createHTTP(dataURI);
    reasoner = new GenericRuleReasoner(Rule.rulesFromURL(path + rulesPath));
    // File f = new File(dataDir);
    // if (!f.exists()) {
    // f.mkdirs();
    // }
    // try {
    // System.out.println("DB files are present at: " +
    // f.getCanonicalPath());
    // } catch (IOException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    // Location location = Location.create(dataDir);
    // dataset = TDBFactory.createDataset(location);
    // if (dataset.listNames().hasNext()) {
    // alreadyExist = true;
    // }
    // base = dataset.getDefaultModel();
    base = accessor.getModel();
    OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM;
    ontModelSpec.setReasoner(reasoner);
    ontModel = ModelFactory.createOntologyModel(ontModelSpec, base);

    if (base.isEmpty()) {
      // om = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, base);
      // base = ModelFactory.createDefaultModel();
      loadData();
      // runReasoner();
      saveData();
      // accessor.putModel(ontModel);
    }
  }
Пример #2
0
 /**
  * Utility method that can be used by classes in this package. It creates a new specification for
  * OWL DL models that are stored in memory and do no additional entailment reasoning, i.e., the
  * reasoner is initially set <code>null</code>.
  *
  * <p>Furthermore, the model specification delegates to the global <tt> OntDocumentManager</tt>
  * provided by Jena. Consequently, all the global settings are used, such as alternative paths,
  * prefix mappings, ignored ontologies, and the global cache (if not disabled). Note that
  * modifying the internal state of the document manager may cause inferences in multithreaded
  * environments, e.g., modifying the set of ignored ontologies by one thread while another thread
  * reads the set at the same time.
  *
  * @return A new ontology model specification.
  */
 static OntModelSpec createOntSpec() {
   OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_DL_MEM);
   spec.setDocumentManager(OntDocumentManager.getInstance());
   return spec;
 }