Examples of OntModel


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

    checkConsistency(m,new File(rdf+"/sequenceUnambiguous.rdf"));
  }

  @Test public void testSimpleContent() throws Exception {
    gloze = new Gloze(SILENT);
    OntModel m = runTest(new File(xsd+"/simpleContent.xsd"));
    checkConsistency(m,new File(rdf+"/simpleContentExtension.rdf"));
    checkConsistency(m,new File(rdf+"/simpleContentRestriction.rdf"));
  }
View Full Code Here

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

    checkConsistency(m,new File(rdf+"/simpleContentRestriction.rdf"));
  }

  @Test public void testSimpleType() throws Exception {
    gloze = new Gloze(SILENT);
    OntModel m = runTest(new File(xsd+"/simpleType.xsd"));
    checkConsistency(m,new File(rdf+"/simpleType.rdf"));
    checkConsistency(m,new File(rdf+"/simpleTypeList1.rdf"));
    checkConsistency(m,new File(rdf+"/simpleTypeList2.rdf"));
    checkConsistency(m,new File(rdf+"/simpleTypeList2Empty.rdf"));
    checkConsistency(m,new File(rdf+"/simpleTypeList3.rdf"));
View Full Code Here

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

    runTest(new File(xsd+"/substitution.xsd"));
  }

  @Test public void testUnion() throws Exception {
    gloze = new Gloze(SILENT);
    OntModel m = runTest(new File(xsd+"/union.xsd"));
    checkConsistency(m,new File(rdf+"/unionSimpleType.rdf"));
  }
View Full Code Here

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

//      setName(src.getName());
      Gloze.logger.info(src.getName());
     
      currentBase = base;
      if (currentBase.endsWith("/")) currentBase += changeSuffix(src.getName(), "owl");
      OntModel ont = gloze.xsd_to_owl(src, currentBase);

      OntModel ont1 = ModelFactory.createOntologyModel();
      // ignore all ontologies imported during testing
      ont1.getDocumentManager().setProcessImports(false);
     
      File owlDir = new File(owl);
      if (!owlDir.exists()) try {
        owlDir.mkdir();
      } catch (Exception e) {
        e.printStackTrace();
      }

      File target = new File(owl, changeSuffix(src.getName(), "owl"));
      if (target.exists()) {
        ont1.read(new FileInputStream(target),currentBase,LANG);
        assertTrue(ont.isIsomorphicWith(ont1));
      }
      // write it the first time
      else {
        // set base
View Full Code Here

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

  }

  /** add subclass relationships */

  public void subClassSimpleType(Resource cls, Context ctx) {
    OntModel ont = (OntModel) cls.getModel();
    String t = expandQName(ctx.getDefaultNS(),base, ont);
    if (t!=null && t.startsWith(schema.XSD_URI)) {
      Resource r = schema.toOWL(ont,t);
      if (r!=null) cls.addProperty(RDFS.subClassOf,r);
    }     
View Full Code Here

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

    String tns = xs.getTargetNamespace();
    rest.adjust(xs.ont);
    List<OntClass> restrictions = new Vector<OntClass>();
    // minCardinality (and cardinality)
    for (String key: rest.getMinCard().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.createOntProperty(key);
      Integer minCard = rest.getMinCard().get(key);
      // maxCard includes occurrences of any
      Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key), rest.getAny(key,tns));
      if (maxCard!=null && minCard==maxCard)
        restrictions.add(xs.ont.createCardinalityRestriction(null,p,minCard));
      else if (minCard>0)
        restrictions.add(xs.ont.createMinCardinalityRestriction(null,p,minCard));
    }
    // maxCardinality
    for (String key: rest.getMaxCard().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.createOntProperty(key);
      int m = rest.getMaxCard().get(key);
      if (m==Integer.MAX_VALUE) continue;
      Integer minCard = rest.getMinCard().get(key);
      Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key),  rest.getAny(key,tns));
      if (minCard==null || minCard!=maxCard)
        restrictions.add(xs.ont.createMaxCardinalityRestriction(null,p,maxCard));
    }
   
    // add value restrictions   
    for (String key: rest.getRange().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.getOntProperty(key);
      Set<Resource> s = rest.getRange().get(key);

      if (s.size()==1) {
        Resource t = s.iterator().next();
       
View Full Code Here

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

      log.debug("retrieveModel: uri: " +uriModel+ "  version: " +version);
    }
   
    String str = resolveOntologyUri(uriModel, version, "application/rdf+xml");
   
    OntModel model = createDefaultOntModel();
    uriModel = JenaUtil2.removeTrailingFragment(uriModel);
   
    StringReader sr = new StringReader(str);
   
    try {
      model.read(sr, uriModel);
    }
    catch (Exception e) {
      log.warn("Error reading model from retrieved contents: [" +str+ "]", e);
      throw e;
    }
View Full Code Here

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

 
  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

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

   
    String ontologyUri = ontology.getUri();
    String serialization;
   
    if ( USE_UNVERSIONED ) {
      OntModel model = JenaUtil2.loadModel("file:" +full_path, false);

      if ( OntUtil.isOntResolvableUri(ontologyUri) ) {
        MmiUri mmiUri;
        try {
          mmiUri = new MmiUri(ontologyUri);
          OntModel unversionedModel = UnversionedConverter.getUnversionedModel(model, mmiUri);
         
          serialization = JenaUtil2.getOntModelAsString(unversionedModel, "RDF/XML-ABBREV");
         
          ontologyUri = mmiUri.copyWithVersion(null).getOntologyUri();
        }
        catch (URISyntaxException e) {
          log.error("shouldn't happen", e);
          return ;
        }
        log.info("To load Ont-resolvable ontology in graph.");
      }
      else {
        serialization = JenaUtil2.getOntModelAsString(model, "RDF/XML-ABBREV");
        log.info("To load re-hosted ontology in graph.");
      }
    }
    else {
      OntModel model = JenaUtil2.loadModel("file:" +full_path, false);
      serialization = JenaUtil2.getOntModelAsString(model, "RDF/XML-ABBREV");
    }
   
    ///////////////////////////////////////////////////////////////
    // now, update graph with model captured in serialization
View Full Code Here

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

   
    if ( log.isDebugEnabled() ) {
      log.debug("getOntologyMetadata(RegisteredOntologyInfo): loading model");
    }
   
    OntModel ontModel;
    try {
      ontModel = OntServiceUtil.retrieveModel(registeredOntologyInfo.getUri(), version);
    }
    catch (Exception e) {
      String error = "Error loading model: " +e.getMessage();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.