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

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


   
    while ( it.hasNext() )
      {
      Statement currFailure = it.nextStatement();
      Resource subj = currFailure.getSubject();
      NodeIterator it2 = repair.listObjectsOfProperty( subj, EYE.repairType );
      while ( it2.hasNext() )
        {
        RDFNode curr = it2.nextNode();
        if ( curr.equals( EYE.decreaseNumProperties ) )
          {
          NodeIterator it3 = repair.listObjectsOfProperty( subj, EYE.statementRemoved );
          while ( it3.hasNext() )
            {
            Resource remStat = (Resource)it3.nextNode();
            Resource remS = (Resource)repair.listObjectsOfProperty( remStat, RDF.subject ).nextNode();
            Property remP = output.createProperty( repair.listObjectsOfProperty( remStat, RDF.predicate ).nextNode().asNode().getURI() );
            RDFNode remO = repair.listObjectsOfProperty( remStat, RDF.object ).nextNode();
            output.remove( remS, remP, remO );
            }
          }
        else if ( curr.equals( EYE.increaseNumProperties ) )
          {
          Resource addStat = (Resource)repair.listObjectsOfProperty( subj, EYE.statementAdded ).nextNode();
          Resource addS = (Resource)repair.listObjectsOfProperty( addStat, RDF.subject ).nextNode();
          Property addP = output.createProperty( repair.listObjectsOfProperty( addStat, RDF.predicate ).nextNode().asNode().getURI() );
          int target = Integer.parseInt( repair.listObjectsOfProperty( repair.createResource( repair.listObjectsOfProperty( subj, EYE.cardinality ).nextNode().asNode().getBlankNodeId() ), EYE.min ).nextNode().asNode().getLiteralLexicalForm() );
          int start = Integer.parseInt( repair.listObjectsOfProperty( subj, EYE.numValues ).nextNode().asNode().getLiteralLexicalForm() );
          for ( int i = start; i < target; i++ )
            output.add( addS, addP, output.createResource() );
          }
        else if ( curr.equals( EYE.increaseCardinality ) )
          {
          int target = Integer.parseInt( repair.listObjectsOfProperty( subj, EYE.max ).nextNode().asNode().getLiteralLexicalForm() );
          int minCard = Integer.parseInt( repair.listObjectsOfProperty( repair.createResource( repair.listObjectsOfProperty( subj, EYE.cardinality ).nextNode().asNode().getBlankNodeId() ), EYE.min ).nextNode().asNode().getLiteralLexicalForm() );
          Resource cName = output.createResource( ((OntModel)output).getBaseModel().listObjectsOfProperty( output.createResource( repair.listObjectsOfProperty( subj, EYE.onType).nextNode().asNode().getURI() ), RDFS.subClassOf ).nextNode().asNode().getBlankNodeId() );
          StmtIterator it3 = output.listStatements( cName, OWL.cardinality, (RDFNode)null );
          if ( it3.hasNext() )
            {
            output.remove( it3 );
            output.add( cName, OWL.minCardinality, output.createTypedLiteral( "" + minCard, "http://www.w3.org/2001/XMLSchema#integer" ) );
            }
          else
View Full Code Here


    {
    Resource curr = it2.nextResource();
    // Try and compare the number of usages of clashing classes; instruct to delete if one outweighs the other
    Resource from = input.createResource( repair.listObjectsOfProperty( curr, EYE.noConsistentTypeFor ).nextNode().asNode().getURI() );
   
    NodeIterator it3 = ((OntModel)input).getBaseModel().listObjectsOfProperty( from, RDF.type );
    ArrayList<String> l = new ArrayList<String>();
    String popular = null;
    int popCount = 0;
    while ( it3.hasNext() )
      {
      String test = it3.nextNode().asNode().getURI();
      int testCount = typeCounts[ types.indexOf( test ) ];
      if ( testCount > popCount )
        {
        popCount = testCount;
        if ( popular != null )
View Full Code Here

    this.repair = report;
    this.output = this.input;
   
    ResIterator it = repair.listSubjectsWithProperty( EYE.hasNoType );
    while ( it.hasNext() ) {
      NodeIterator it2 = repair.listObjectsOfProperty( it.nextResource(), EYE.statementAdded );
      while ( it2.hasNext() )
        {
        Resource bnode = repair.createResource( it2.nextNode().asNode().getBlankNodeId() );
       
        Resource subj =  (Resource)repair.listObjectsOfProperty( bnode, RDF.subject ).nextNode();
        Property pred = output.createProperty( repair.listObjectsOfProperty( bnode, RDF.predicate ).nextNode().asNode().getURI() );
        RDFNode obj = repair.listObjectsOfProperty( bnode, RDF.object ).nextNode();
       
View Full Code Here

      };
      String[] children = dir.list( rdfxml );
      if ( children != null )
        namespaces = children.clone();
   
    NodeIterator it = repair.listObjectsOfProperty( EYE.unknownPredicate );
    while ( it.hasNext() )
      {
      curr = it.nextNode();
     
      boolean fixed = false;
      for ( int j = 0; j < namespaces.length; j++ )
        {
        Model currNS = ModelFactory.createDefaultModel().read( "file:" + nsBase + "/" + namespaces[j] );
View Full Code Here

   
    it = repair.listSubjectsWithProperty( EYE.repairType, EYE.removeDuplicatePrefixes );
    while ( it.hasNext() )
      {
      Resource curr = it.nextResource();
      NodeIterator it2 = repair.listObjectsOfProperty( curr, EYE.onPrefix );
        String uri = repair.listObjectsOfProperty( curr, EYE.multiplePrefixesForNamespace ).nextNode().asNode().getLiteralLexicalForm();
        if (it2.hasNext())
          {
          boolean oneKept = false;
          while ( it2.hasNext() )
            {
            RDFNode curra = it2.nextNode();
            if ( m.getNsPrefixURI( curra.asNode().getLiteralLexicalForm() ) != null )
              if ( m.getNsPrefixURI( curra.asNode().getLiteralLexicalForm() ).equals( uri ) )   // The prefix is still used in the model
                {
                if ( oneKept )
                  m.removeNsPrefix( curra.asNode().getLiteralLexicalForm() );
View Full Code Here

      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

   
      ResIterator it = repair.listSubjectsWithProperty( EYE.unknownPredicate );
      while ( it.hasNext() )
        {
        Resource curr = it.nextResource();
        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 );
View Full Code Here

     
      ResIterator it1 = repair.listSubjectsWithProperty( EYE.badURI );
      while( it1.hasNext() )
        {
        Resource curr = it1.nextResource();
        NodeIterator it2 = repair.listObjectsOfProperty( curr, EYE.forReason );
        RDFNode uri = repair.listObjectsOfProperty( curr, EYE.badURI ).nextNode();
        String work = uri.asNode().getLiteralLexicalForm();
        while ( it2.hasNext() )
          {
          String fault = it2.nextNode().asNode().getURI();
          repair.add( curr, EYE.checkFix, RDF.subject );
          repair.remove( repair.listStatements( curr, EYE.newValue, work ) );
          if ( fault.contains( "unrecognisedScheme" ) )
              { String fixed = analyseUnrecognisedScheme( config, curr, work );
              }
View Full Code Here

          for ( int i = 0 ; i < work.length(); i++)
            if ( work.charAt( i ) == ':' )
              break;
            else
              scheme += work.charAt( i );
          NodeIterator it2b = config.listObjectsOfProperty( EYE.validScheme );
          String wordList = "";
          while ( it2b.hasNext() )
            wordList += it2b.nextNode().asNode().getLiteralLexicalForm() + '\n';
          GenericWordChecker check = new WordChecker( wordList );
          Iterator<Word> sugg = check.spellCheck( scheme );
          if ( sugg != null )
            fixed = sugg.next().toString();
          }
View Full Code Here

  public void getContainerResources (Resource resource,
      Model model, String resourceName) {
    try {
        //No Container
        Container resourceBag = (Container) resource;
        NodeIterator nodeI = resourceBag.iterator();
        //OntResource resourceBag = (OntResource) resource;
        //NodeIterator nodeI = resourceBag.listPropertyValues(null);
        while(nodeI.hasNext()) {
          RDFNode node = nodeI.nextNode();
          System.out.println("   node to check:" + node);               
          if(node.isResource()) {
            NodeIterator nodess = model.listObjectsOfProperty((Resource)node,null);
            while(nodess.hasNext()) {
              RDFNode profile = nodess.nextNode();
              System.out.println("     " + profile);               
            }
          }           
          //System.out.println("   triple "+statement.getPredicate()+" - "+statement.getObject());
        }
View Full Code Here

TOP

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

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.