Package com.hp.hpl.jena.ontology

Examples of com.hp.hpl.jena.ontology.OntModel


*
* @author Carlos Rueda
*/
class ModelLoader {
  static OntModel loadModel(String uriModel, boolean includeImports) {
    OntModel model = createDefaultOntModel();
    uriModel = _removeTrailingFragment(uriModel);
   
    model.setDynamicImports(false);
    model.getDocumentManager().setProcessImports(includeImports);
   
    model.read(uriModel);
    return model;
  }
View Full Code Here


  private static OntModel createDefaultOntModel() {
    OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_MEM);
    OntDocumentManager docMang = new OntDocumentManager();
    spec.setDocumentManager(docMang);
    OntModel model = ModelFactory.createOntologyModel(spec, null);
    // removeNotNeccesaryNamespaces(model);

    return model;
  }
View Full Code Here

  private static final String ONTOLOGY_URI = "http://localhost:8080/ont/mmitest/VineTest";

 
  public void testOther001() throws Exception {
    String filename = BASE_DIR_OTHER+ "sweet_top.owl";
    OntModel ontModel = _load(new File(filename));
   
    String ontologyUri = "http://sweet.jpl.nasa.gov/2.0/top.owl";
    OntologyType ontype = OntTypeUtil.determineType(ontModel, ontologyUri, null);
    assertEquals("ontology type should be Other", OntologyType.OTHER, ontype);
View Full Code Here

   
    if ( log.isDebugEnabled() ) {
      log.debug("simplename=" +simplename+ " , ontologyUri=" +ontologyUri);
    }
    String filename = BASE_DIR_VINE+ simplename;
    OntModel ontModel = _load(new File(filename));
   
    OntologyType ontype = OntTypeUtil.determineType(ontModel, ontologyUri, null);
    assertEquals("ontology type should be MAPPING", OntologyType.MAPPING, ontype);

    TempOntologyInfo baseOntologyInfo = new TempOntologyInfo();
View Full Code Here

  }

  /** reads an ontology model from a file */
  public static OntModel readOntModel(File file) throws IOException {
    String uriModel = file.toURI().toString();
    OntModel model = ModelFactory.createOntologyModel();
    model.setDynamicImports(false);
    model.getDocumentManager().setProcessImports(false);
    model.read(uriModel);
    return model;
  }
View Full Code Here

    return model;
  }
 
  /** reads an ontology model from a string */
  public static OntModel readOntModel(String contents) throws IOException {
    OntModel model = ModelFactory.createOntologyModel();
    model.setDynamicImports(false);
    model.getDocumentManager().setProcessImports(false);
    model.read(new StringReader(contents), null);
    return model;
  }
View Full Code Here

    RetrieveResult retrievalResult = RetrieveOntology.retrieveOntology(ontologyUri, version, format);
    assertEquals(HttpStatus.SC_OK, retrievalResult.status);
    assertNotNull(retrievalResult.body);
    assertTrue(retrievalResult.body.contains("<rdf:RDF"));
   
    OntModel model = Utils.readOntModel(retrievalResult.body);

    return model;
  }
View Full Code Here

   */
  @Test
  public void test31() throws Exception {
    System.out.println("** test31");
   
    OntModel model = retrieveOntology();

    // add a new statement for termUri in the model:
    Resource termResource = ResourceFactory.createResource(termUri);
    Property description = ResourceFactory.createProperty(descriptionUri);
    String descriptionString = "Generated description " +System.currentTimeMillis();
    Literal descriptionObject = ResourceFactory.createPlainLiteral(descriptionString);
    Statement statement = ResourceFactory.createStatement(termResource, description, descriptionObject);
    model.add(statement);
    System.out.println("New statement: " +statement);
   
    // register a new version with this updated model:
    registerOntology(model);
   
    // retrieve model again a verify that it contains our new statement
    OntModel model2 = retrieveOntology();
    assertTrue( model2.contains(statement) );
  }
View Full Code Here

    // Verify that both models contain exactly the same statements, except for
    // the ontology metadata.
   
    // first, create corresponding models:
    // model for the original file:
    OntModel model1 = Utils.readOntModel(new File(fileName));
    // model for the retrieved file:
    OntModel model2 = Utils.readOntModel(retrievedOntologyContents);
   
    // check that the models are isomorphic but ignoring all statements about
    // the ontology resource:
    Resource ontologyResource = ResourceFactory.createResource(ontologyUri);
    model1.removeAll(ontologyResource, null, null);
    model2.removeAll(ontologyResource, null, null);
    // .. and now compare
    assertTrue(model1.isIsomorphicWith(model2));
  }
View Full Code Here

   
    RetrieveResult retrievalResult = RetrieveOntology.retrieveOntology(vocabularyUri, version, format);
    assertEquals(HttpStatus.SC_OK, retrievalResult.status);
    assertNotNull(retrievalResult.body);
    assertTrue(retrievalResult.body.contains("<rdf:RDF"));
    OntModel model = Utils.readOntModel(retrievalResult.body);
   
    // the following shows the metadata ie. properties with vocabularyUri as subject:
    // false: not included to avoid cluttering the test output
    if ( false ) {
      Resource ontologyResource = ResourceFactory.createResource(vocabularyUri);
      StmtIterator metadata = model.listStatements(ontologyResource, null, (RDFNode) null);
      while ( metadata.hasNext() ) {
        Statement stmt = metadata.nextStatement();
        System.out.println("\t" +stmt.getPredicate()+ " -> " +stmt.getObject());
      }
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.OntModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.