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

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


  public void analyse( Report r, Model m, Model config )
  {
  this.input = m;
  this.repair = r.model();
 
  StmtIterator it = ((OntModel)input).getBaseModel().listStatements( null, RDF.type, (RDFNode)null );
  int[] typeCounts = new int[ ((OntModel)input).getBaseModel().listObjectsOfProperty( RDF.type ).toList().size() ];
  for ( int i = 0; i < typeCounts.length; i++ )
    typeCounts[i] = 0;
  ArrayList<String> types = new ArrayList<String>();
  while ( it.hasNext() )
    {
    String currType = it.nextStatement().getObject().asNode().getURI();
    if ( !types.contains( currType ) )
      types.add( currType );
    typeCounts[ types.indexOf( currType ) ]++;
    }
 
View Full Code Here


     
      boolean fixed = false;
      for ( int j = 0; j < namespaces.length; j++ )
        {
        Model currNS = ModelFactory.createDefaultModel().read( "file:" + nsBase + "/" + namespaces[j] );
        StmtIterator iter = currNS.listStatements( (Resource)null, RDF.type, (RDFNode)null );
        while( iter.hasNext() )
          {
          Resource thisSubj = iter.nextStatement().getSubject();
          if ( thisSubj.getLocalName() != null )
            if ( thisSubj.getLocalName().equals( curr.asNode().getLocalName() ) )
              {
                fixURI( thisSubj.getURI() );
                fixed = true;
View Full Code Here

  private String getConfigsPrefixFromUri ( String uri )
    {
    ResIterator subjects = config.listSubjectsWithProperty( EYE.nsURI, config.createLiteral( uri ) );
    if ( subjects.hasNext() )
      {
      StmtIterator prefixes = config.listStatements( subjects.nextResource(), EYE.prefix, (RDFNode)null );
      if ( prefixes.hasNext() )
        return prefixes.nextStatement().getObject().asNode().getLiteralLexicalForm();
      }
    return null; // Return null otherwise
    }
View Full Code Here

  private String getConfigsUriFromPrefix ( String pre )
    {
    ResIterator subjects = config.listSubjectsWithProperty( EYE.prefix, config.createLiteral( pre ) );
    if ( subjects.hasNext() )
      {
      StmtIterator uris = config.listStatements( subjects.nextResource(), EYE.nsURI, (RDFNode)null );
      if ( uris.hasNext() )
        return uris.nextStatement().getObject().asNode().getLiteralLexicalForm();
      }
    return null; // Return null otherwise
    }
View Full Code Here

     *   o Set the prefix of 'from' to be that of 'to'
     */
    Model toAdd = ModelFactory.createDefaultModel();
    Model toDel = ModelFactory.createDefaultModel();
    Resource newUri = output.createResource( to );
    StmtIterator it = output.listStatements( output.createResource( from ), null, (RDFNode)null );
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      toDel.add( curr );
      toAdd.add( newUri, curr.getPredicate(), curr.getObject() );
      }
   
    it = output.listStatements( null, null, output.createResource( from ) );
    while ( it.hasNext() )
      {
      Statement curr = it.nextStatement();
      toDel.add( curr );
      toAdd.add( curr.getSubject(), curr.getPredicate(), newUri );
      }
   
    output.remove( toDel );
View Full Code Here

    {
    this.input = m;
    this.repair = report;
    this.output = this.input;

      StmtIterator it = repair.listStatements( (Resource)null, EYE.notFromSchema, (RDFNode)null );
      while ( it.hasNext() )
        {
      subject = it.nextStatement().getSubject();                
      curr = repair.listObjectsOfProperty( subject, EYE.onResource ).nextNode();
        NodeIterator it2 = repair.listObjectsOfProperty( subject, EYE.newValue );
        if ( it2.hasNext() )
          fixURI( it2.nextNode().asNode().getLiteralLexicalForm() );
        }                           
View Full Code Here

        NodeIterator it2 = repair.listObjectsOfProperty( curr, EYE.newValue );
       
        if ( it2.hasNext() )
          {
          // Replace all instances of statement predicate curr in input with replacement
          StmtIterator it3 = input.listStatements((Resource)null, input.createProperty( repair.listObjectsOfProperty( curr, EYE.unknownPredicate ).nextNode().asNode().getURI() ), (RDFNode)null);
          Model toDel = ModelFactory.createDefaultModel();
          Model toAdd = ModelFactory.createDefaultModel();
          String replacement = it2.nextNode().asNode().getLiteralLexicalForm();
         
          while( it3.hasNext() )
            {
            Statement torem = it3.nextStatement();
            toDel.add( torem );
            toAdd.add( torem.getSubject(), toAdd.createProperty( replacement ), torem.getObject() );
            }
         
          input.remove( toDel );
View Full Code Here

    this.cleanModel();
  }

  private  void loadRelationsWeight() {
    Model model = getRDFModel();
    StmtIterator itr = model.listStatements();

    while(itr.hasNext()) {
      Statement stmt = itr.nextStatement();
      Double weight = new Double(stmt.getObject().toString());
      weightTable.put(stmt.getSubject().getURI(), weight);
    }
    this.weightTable.put(DEFAULT_URI,DEFAULT_VALUE);
  }
View Full Code Here

    }
    // Limited Attributes and Properties of Community Class //
    // identifier //
    Property identifier = ResourceFactory.createProperty(
        riNamespace + "identifier");
    StmtIterator stmtI1 = model.listStatements(resource,
        identifier, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate identifier property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "identifier property of Community resource:"+
            resource.getURI()+" is not a literal")) {
View Full Code Here

    addResourceInstanceToCache(resource, onlAcc);
    // Specific Attributes and Properties of Foaf:OnlineAccount Class //
    // foafAccountName //
    Property foafAccountName = ResourceFactory.createProperty(
        foafNamespace + "accountName");
    StmtIterator stmtI1 = model.listStatements(resource,
        foafAccountName, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate name property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.ONLINEACCOUNT,
            "name property of OnlineAccount resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        onlAcc.setName(statement.getObject().asLiteral().getString());
      }
    }
    // foafAccountProfilePage //
    Property foafAccountProfilePage = ResourceFactory.createProperty(
        foafNamespace + "accountProfilePage");
    stmtI1 = model.listStatements(resource,
        foafAccountProfilePage, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate name property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.ONLINEACCOUNT,
            "name property of OnlineAccount resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        onlAcc.setUrl(statement.getObject().asLiteral().getString());
      }
    }
    // belongsTo //
    Property belongsTo = ResourceFactory.createProperty(
        riNamespace + "belongsTo");   
    stmtI1 = model.listStatements(resource,
        belongsTo, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate belongsTo property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.ONLINEACCOUNT,
            "belongsTo property of resource:"+
            resource.getURI()+" is not a resource")) {
View Full Code Here

TOP

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

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.