Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Statement


    if ( ontRes != null ) {
      prexistStatements = new ArrayList<Statement>();
      log.info("Getting pre-existing properties for OWL.Ontology individual: " +ontRes.getURI());
      StmtIterator iter = ontRes.listProperties();
      while ( iter.hasNext() ) {
        Statement st = iter.nextStatement();
        prexistStatements.add(st);
     
    }

   
    // The new OntModel that will contain the pre-existing attributes (if any),
    // plus the new and updated attributes:
    final OntModel newOntModel = _createOntModel(model);
    final Ontology ont_ = newOntModel.createOntology(base_);
    log.info("New ontology created with namespace " + ns_ + " base " + base_);
    newOntModel.setNsPrefix("", ns_);
   
    // set preferred prefixes:
    Map<String, String> preferredPrefixMap = MdHelper.getPreferredPrefixMap();
    for ( String uri : preferredPrefixMap.keySet() ) {
      String prefix = preferredPrefixMap.get(uri);
      newOntModel.setNsPrefix(prefix, uri);
    }
   
   
    // Set internal attributes, which are updated in the newValues map itself
    // so we facilite the processing below:
    newValues.put(Omv.version.getURI(), version);
   
    newValues.put(Omv.creationDate.getURI(), creationDate);
   
   
    // set some properties from the explicit values
    newValues.put(OmvMmi.origMaintainerCode.getURI(), orgAbbreviation);


    //////////////////////////////////////////////////
    // transfer any preexisting attributes, and then remove all properties from
    // pre-existing ontRes so just the new OntModel gets added.
    if ( ontRes != null ) {
      for ( Statement st : prexistStatements ) {
        Property prd = st.getPredicate();

        //
        // Do not tranfer pre-existing/pre-assigned-above attributes
        //
        String newValue = newValues.get(prd.getURI());
        if ( newValue == null || newValue.trim().length() == 0 ) {
          log.info("  Transferring: " +st.getSubject()+ " :: " +prd+ " :: " +st.getObject());
          newOntModel.add(ont_, prd, st.getObject());
        }
        else {
          log.info(" Removing pre-existing values for predicate: " +prd+ " because of new value " +newValue);
          newOntModel.removeAll(ont_, prd, null);
        }
View Full Code Here


      if ( log.isDebugEnabled() ) {
        log.debug("Getting pre-existing properties from Ontology: " +ont.getURI());
      }
      StmtIterator iter = ont.listProperties();
      while ( iter.hasNext() ) {
        Statement st = iter.nextStatement();
        prexistStatements.add(st);
     
    }

   
    // The new OntModel that will contain the pre-existing attributes (if any),
    // plus the new and updated attributes:
    final OntModel newOntModel = OntModelUtil.createOntModel(base_, true, model);
    JenaUtil2.setOntologyUriForGetOntology(base_);
    final Ontology ont_ = JenaUtil2.getOntology(newOntModel);
    if ( log.isDebugEnabled() ) {
      log.debug("New ontology created with namespace " + ns_ + " base " + base_);
    }
   
    // Set internal attributes, which are updated in the newValues map itself
    // so we facilite the processing below:
    newValues.put(Omv.version.getURI(), version);
    newValues.put(Omv.creationDate.getURI(), creationDate);
   

    //////////////////////////////////////////////////
    // transfer any preexisting attributes, and then remove all properties from
    // pre-existing ont so just the new OntModel gets added.
    if ( prexistStatements != null ) {
      for ( Statement st : prexistStatements ) {
        Property prd = st.getPredicate();

        //
        // Do not tranfer pre-existing/pre-assigned-above attributes
        //
        String newValue = newValues.get(prd.getURI());
        if ( newValue == null || newValue.trim().length() == 0 ) {
          if ( log.isDebugEnabled() ) {
            log.debug("  Transferring: " +st.getSubject()+ " :: " +prd+ " :: " +st.getObject());
          }
          newOntModel.add(ont_, prd, st.getObject());
        }
        else {
          if ( log.isDebugEnabled() ) {
            log.debug(" Removing pre-existing values for predicate: " +prd+ " because of new value " +newValue);
          }
View Full Code Here

    if ( ontRes != null ) {
      prexistStatements = new ArrayList<Statement>();
      log.info("Getting pre-existing properties for OWL.Ontology individual: " +ontRes.getURI());
      StmtIterator iter = ontRes.listProperties();
      while ( iter.hasNext() ) {
        Statement st = iter.nextStatement();
        prexistStatements.add(st);
     
    }

   
    // The new OntModel that will contain the pre-existing attributes (if any),
    // plus the new and updated attributes:
    final OntModel newOntModel = _createOntModel(model);
    final Ontology ont_ = newOntModel.createOntology(base_);
    log.info("New ontology created with namespace " + ns_ + " base " + base_);
    newOntModel.setNsPrefix("", ns_);
   
    // set preferred prefixes:
    Map<String, String> preferredPrefixMap = MdHelper.getPreferredPrefixMap();
    for ( String uri : preferredPrefixMap.keySet() ) {
      String prefix = preferredPrefixMap.get(uri);
      newOntModel.setNsPrefix(prefix, uri);
    }
   
   
    // Set internal attributes, which are updated in the newValues map itself
    // so we facilite the processing below:
    newValues.put(Omv.uri.getURI(), base_);
    newValues.put(Omv.version.getURI(), version);
   
    newValues.put(Omv.creationDate.getURI(), creationDate);


    //////////////////////////////////////////////////
    // transfer any preexisting attributes, and then remove all properties from
    // pre-existing ontRes so just the new OntModel gets added.
    if ( ontRes != null ) {
      for ( Statement st : prexistStatements ) {
        Property prd = st.getPredicate();

        //
        // Do not tranfer pre-existing/pre-assigned-above attributes
        //
        String newValue = newValues.get(prd.getURI());
        if ( newValue == null || newValue.trim().length() == 0 ) {
          log.info("  Transferring: " +st.getSubject()+ " :: " +prd+ " :: " +st.getObject());
          newOntModel.add(ont_, prd, st.getObject());
        }
        else {
          log.info(" Removing pre-existing values for predicate: " +prd+ " because of new value " +newValue);
          newOntModel.removeAll(ont_, prd, null);
        }
View Full Code Here

    return model;
  }

  // verbatim copy from JenaUtil
  public static String getValue(Resource sub, Property pro) {
    Statement sta = sub.getProperty(pro);
    if (sta != null) {
      RDFNode node = sta.getObject();
      return getValueAsString(node);
    } else {
      return null;
    }
  }
View Full Code Here

  // verbatim copy from JenaUtil except for the generics supportee by the recent jena version
  public static Resource getFirstIndividual(Model model, Resource resType) {
    StmtIterator iter = model.listStatements(null, RDF.type, resType);
    if (iter.hasNext()) {
      Statement sta = (Statement) iter.next();
      return (Resource) sta.getSubject();
    } else
      return null;
  }
View Full Code Here

        obj = ResourceFactory.createResource(objLab);
      }
      else {
        obj = ResourceFactory.createPlainLiteral(objLab);
      }
      Statement stmt = ResourceFactory.createStatement(sbj, prd, obj)
       
      model.add(stmt);
      }
     
    return model;
View Full Code Here

  }
 
  public static Resource addConceptSubClass(Model model, String conceptUri ) {
    Resource conceptSubClass = model.createResource(conceptUri);
   
    Statement stmt;
   
    stmt = model.createStatement(conceptSubClass, RDF.type, OWL.Class);
    model.add(stmt);
   
    stmt = model.createStatement(conceptSubClass, RDFS.subClassOf, Skos.Concept);
View Full Code Here

      Resource conceptSubClass,
      String propUri, String propLabel
  ) {
    Property prop = model.createProperty(propUri);
   
    Statement stmt;
   
    stmt = model.createStatement(prop, RDF.type, OWL.DatatypeProperty);
    model.add(stmt);
    stmt = model.createStatement(prop, RDFS.domain, conceptSubClass);
    model.add(stmt);
View Full Code Here

      }
    }
   
    StmtIterator iter = ontModel.listStatements();
    while ( iter.hasNext() ) {
      final Statement stmt = iter.nextStatement();
     
      final Resource sbj = stmt.getSubject();
      final Property prd = stmt.getPredicate();
      final RDFNode obj = stmt.getObject();
     
      if ( sbj.isAnon() ) {
        continue;
      }
     
View Full Code Here

    // 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);
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Statement

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.