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

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


            riNamespace + "importsFrom");
       
        addPropertiesAndResources();
       
        for(Resource agent : resources) {                          
            ResIterator iters = model.listResourcesWithProperty(RDF.type,agent);
            if (iters.hasNext()) {
                System.out.println("The database contains resource for:");
                while (iters.hasNext()) {
                    Resource resource = iters.nextResource();
                    String resourceName = null;
                    if(resource.getLocalName() != null) {
                            resourceName = resource.getLocalName();
                    } else if(resource.getId() != null) {
                      if(resource.getId().getLabelString() != null) {
                        resourceName = resource.getId().getLabelString();
                        } else {
                          resourceName = resource.getId().toString();
                        }
                    } else if(resource.getURI() != null) {
                            resourceName = resource.getURI();
                    }
                    System.out.println("  " + resourceName+" class:"+resource.getClass());
                    NodeIterator nodes = model.listObjectsOfProperty(resource, RDF.type);
                    while(nodes.hasNext()) {
                        RDFNode node = nodes.nextNode();
                        if(node.isResource()) {
                                System.out.println("   type " + node.asResource().getURI());
                        }
                    }
                    StmtIterator stmtI = model.listStatements(resource, null, (RDFNode)null);
                    while(stmtI.hasNext()) {
                            Statement statement = stmtI.nextStatement();
                            System.out.println("   triple "+statement.getPredicate()+" - "+statement.getObject());
                    }
                    for(Property property : propertyAccount) {
                        StmtIterator stmtI1 = model.listStatements(resource, property, (RDFNode)null);
                        while(stmtI1.hasNext()) {
                            Statement statement = stmtI1.nextStatement();                                  
                            System.out.println("   OnlineAccount "+statement.getObject());
                            if(statement.getObject().isResource()) {
                                Resource onlineAccount = statement.getObject().asResource();                                                   
                                NodeIterator nodess = model.listObjectsOfProperty(onlineAccount, RDF.type);
                                while(nodess.hasNext()) {
                                    RDFNode node = nodess.nextNode();
                                    if(node.isResource()) {
                                        System.out.println("      type " + node.asResource().getURI());
                                    }
                                }
                                for(Property property2 : propertyAccountName) {
                                    StmtIterator stmtI2 = model.listStatements(onlineAccount, property2, (RDFNode)null);
                                    Statement statement2 = stmtI2.nextStatement();
                                    System.out.println("      AccountName "+statement2.getObject());
                                }
                                for(Property property2 : propertyAccountProfile) {
                                    StmtIterator stmtI2 = model.listStatements(onlineAccount, property2, (RDFNode)null);
                                    Statement statement2 = stmtI2.nextStatement();
                                    System.out.println("      AccountProfile "+statement2.getObject());
                                }
                            }
                        }
                    }
                }
            }
         } 
       
        ResIterator iters = model.listSubjectsWithProperty(RDF.type,dimension);
        if (iters.hasNext()) {
            System.out.println("The database contains subjects of type dimension:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+Dimension were found in the database");
        }
       
        iters = model.listResourcesWithProperty(RDF.type,categoryMatching);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type CategoryMatching:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String "+riNamespace+
                "CategoryMatching were found in the database");
        }
       
        iters = model.listSubjectsWithProperty(RDF.type,fixedCommunitiesTrust);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type fixedCommunitiesTrust:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "FixedCommunitiesTrust were found in the database");
        }
        iters = model.listSubjectsWithProperty(RDF.type,trustBetweenCommunities);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type trustBetweenCommunities:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "trustBetweenCommunities were found in the database");
        }
        iters = model.listSubjectsWithProperty(RDF.type,correlationBetweenDimension);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type CorrelationBetweenDimension:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "CorrelationBetweenDimension were found in the database");
        }
       
        iters = model.listSubjectsWithProperty(RDF.type,logaritmicNumericTransformer);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type LogaritmicNumericTransformer:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "LogaritmicNumericTransformer were found in the database");
        }
        iters = model.listSubjectsWithProperty(RDF.type,linealNumericTransformer);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type linealNumericTransformer:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "linealNumericTransformer were found in the database");
        }       
        iters = model.listSubjectsWithProperty(RDF.type,sqrtNumericTransformer);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type SqrtNumericTransformer:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "SqrtNumericTransformer were found in the database");
        }
       
        iters = model.listSubjectsWithProperty(RDF.type,metric);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type metric:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
                /* identifier */
                StmtIterator stmtI1 = model.listStatements(resource, identifier, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    identifier:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    identifier resource " +
                  "impossible:"+statement.getObject());             
            } else {
              System.out.println("    identifier no literal no resource");
            }
          }
        /* hasDimension */
        stmtI1 = model.listStatements(resource, hasDimension, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    hasDimension impossible:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    hasDimension resource:"+statement.getObject());
              Resource dimResource = statement.getObject().asResource();                 
              StmtIterator stmtI2 = model.listStatements(dimResource,
                   (Property)null, (RDFNode)null);
               while(stmtI2.hasNext()) {
                Statement statement2 = stmtI2.nextStatement();
                System.out.println("      "+statement2.getPredicate().getLocalName()
                    +" "+statement2.getObject());
               }
            } else {
              System.out.println("    hasDimension no literal no resource");
            }
          }
        /* hasScale */
        stmtI1 = model.listStatements(resource, hasScale, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    hasScale impossible:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    hasScale resource:"+statement.getObject());
              Resource scaResource = statement.getObject().asResource();                 
              StmtIterator stmtI2 = model.listStatements(scaResource,
                   (Property)null, (RDFNode)null);
               while(stmtI2.hasNext()) {
                Statement statement2 = stmtI2.nextStatement();
                System.out.println("      "+statement2.getPredicate().getLocalName()
                    +" "+statement2.getObject());
               }
            } else {
              System.out.println("    hasScale no literal no resource");
            }
          }
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "metric were found in the database");
        }
       
        iters = model.listSubjectsWithProperty(RDF.type,collectingSystem);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type collectingSystem:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
                /* name */
                StmtIterator stmtI1 = model.listStatements(resource, name, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    name:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    name resource " +
                  "impossible:"+statement.getObject());             
            } else {
              System.out.println("    name no literal no resource");
            }
          }       
        /* uriFormat */
        stmtI1 = model.listStatements(resource, uriFormat, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    uriFormat:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    uriFormat resource impossible:"
                  +statement.getObject());             
            } else {
              System.out.println("    uriFormat no literal no resource");
            }
          }
            }
        } else {
            System.out.println("No simple String riNamespace+" +
                "collectingSystem were found in the database");
        }       
       
        iters = model.listSubjectsWithProperty(RDF.type,community);
        if (iters.hasNext()) {
            System.out.println("The database contains resources of type community:");
            while (iters.hasNext()) {
                Resource resource = iters.nextResource();
                System.out.println("  " + resource.getLocalName());
                /* identifier */
                StmtIterator stmtI1 = model.listStatements(resource, identifier, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
View Full Code Here


    agentResource.add(ResourceFactory.createResource(foafNamespace + "Agent"));
    agentResource.add(ResourceFactory.createResource(foafNamespace + "Person"));
    Resource person = ResourceFactory.createResource(foafNamespace + "Person" );
   
    for(Resource agent : agentResource) {       
      ResIterator iters = model.listResourcesWithProperty(RDF.type,agent);
      if (iters.hasNext()) {
          System.out.println("The database contains resource Person for:");
          while (iters.hasNext()) {
            Resource resource = iters.nextResource();
            String resourceName = null;
            if(resource.getLocalName() != null) {
              resourceName = resource.getLocalName();
            } else if(resource.getId() != null) {
              if(resource.getId().getLabelString() != null) {
                resourceName = resource.getId().getLabelString();
              } else {
                resourceName = resource.getId().toString();
              }
            } else if(resource.getURI() != null) {
              resourceName = resource.getURI();
            }
            System.out.println("  " + resourceName+" class:"+resource.getClass());
            NodeIterator nodes = model.listObjectsOfProperty(resource, RDF.type);
            while(nodes.hasNext()) {
              RDFNode node = nodes.nextNode();
              if(node.isResource()) {
                System.out.println("   type " + node.asResource().getURI());
              }
            }
            StmtIterator stmtI = model.listStatements(resource, null, (RDFNode)null);
            while(stmtI.hasNext()) {
              Statement statement = stmtI.nextStatement();
              System.out.println("   triple "+statement.getPredicate()+" - "+statement.getObject());
            }
            for(Property property : propertyAccount) {
              StmtIterator stmtI1 = model.listStatements(resource, property, (RDFNode)null);
              while(stmtI1.hasNext()) {
                Statement statement = stmtI1.nextStatement();             
                System.out.println("   OnlineAccount "+statement.getObject());
                if(statement.getObject().isResource()) {
                  Resource onlineAccount = statement.getObject().asResource();                 
                  NodeIterator nodess = model.listObjectsOfProperty(
                      onlineAccount, RDF.type);
                  while(nodess.hasNext()) {
                    RDFNode node = nodess.nextNode();
                    if(node.isResource()) {
                      System.out.println("      type " + node.asResource().getURI());
                    }
                  }
                  for(Property property2 : propertyAccountName) {
                    StmtIterator stmtI2 = model.listStatements(onlineAccount,
                        property2, (RDFNode)null);
                    Statement statement2 = stmtI2.nextStatement();
                    System.out.println("      AccountName "+statement2.getObject());
                  }
                  for(Property property2 : propertyAccountProfile) {
                    StmtIterator stmtI2 = model.listStatements(onlineAccount,
                        property2, (RDFNode)null);
                    Statement statement2 = stmtI2.nextStatement();
                    System.out.println("      AccountProfile "+statement2.getObject());
                  }
                }
               
              }
            }
          }
      }
    }   
   
    ResIterator iters = model.listSubjectsWithProperty(RDF.type,foafNamespace+"Person");
    if (iters.hasNext()) {
        System.out.println("The database contains literal person for:");
        while (iters.hasNext()) {
          Resource resource = iters.nextResource();
          System.out.println("  " + resource.getLocalName());
           // node.
           
        }
    } else {
      System.out.println("No simple String foafNamespace+Person were found in the database");
    }
   
    Property propertyOnlineAccount = ResourceFactory.createProperty(
        foafNamespace, "OnlineAccount");   
    iters = model.listSubjectsWithProperty(propertyOnlineAccount);
    if (iters.hasNext()) {
        System.out.println("The database contains OnlineAccount for:");
        while (iters.hasNext()) {
          Resource resource = iters.nextResource();
          System.out.println("  " + resource.getLocalName());
        }
    } else {
        System.out.println("No PROPERTY OnlineAccount were found in the database");
    }   
   
    iters = model.listSubjectsWithProperty(RDF.type);
    if (iters.hasNext()) {
        System.out.println("The database contains RDF.type for:");
        while (iters.hasNext()) {
          Resource resource = iters.nextResource();
          NodeIterator nodes = model.listObjectsOfProperty(resource, RDF.type);
          String resourceName = null;
          if(resource.getLocalName() != null) {
            resourceName = resource.getLocalName();
          } else if(resource.getId() != null) {
View Full Code Here

             .addProperty(FOAF.mbox,earl.createResource("mailto:jeremy.carroll@hp.com"))
        );
        Iterator<WDSingleTest> it = tests.iterator();
        while (it.hasNext())
          it.next().exec(earl);
        ResIterator rit = earl.listSubjectsWithProperty(RDF.type, EARL.Assertion);
    while (rit.hasNext())
      rit.nextResource().
         addProperty(EARL.assertedBy,assertor)
         .addProperty(EARL.subject, system);
  }
View Full Code Here

  public void testListSubjectsNoRemove()
  {
    final Model m = ModelHelper.modelWithStatements(this,
        "a P b; b Q c; c R a");
    final ResIterator it = m.listSubjects();
    it.next();
    try
    {
      it.remove();
      Assert.fail("listSubjects should not support .remove()");
    }
    catch (final UnsupportedOperationException e)
    {
      JenaTestBase.pass();
View Full Code Here

    {
      subjf[i] = false;
    }

    boolean found = false;
    final ResIterator rIter = model.listSubjects();
    while (rIter.hasNext())
    {
      final Resource subj = rIter.nextResource();
      found = false;
      for (int i = 0; i < num; i++)
      {
        if (subj.equals(subject[i]))
        {
View Full Code Here

      incoming.read(new StringReader(src), null, "N3");

      // Find the bNode that will be rewritten
      final Property name = incoming.createProperty(
          "http://xmlns.com/foaf/0.1/", "name");
      final ResIterator ri = incoming.listSubjectsWithProperty(name,
          "Ian Dickinson");
      final Resource bNode = ri.nextResource();
      ri.close();

      // Rewrite it to ground form
      final int originalCount = bNode.listProperties().toList().size();
      final Resource newR = incoming
          .createResource("http://www.hp.com/people/Ian_Dickinson");
View Full Code Here

    }
    log.debug("...done.");
    System.out.println("Check 2: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));

    Set<Resource> labelednodes = bscrdf.listSubjectsWithProperty(RDFS.label).toSet();
    ResIterator allit = bscrdf.listSubjects();
    ArrayList<String> autocompletelist = new ArrayList<String>();
    while(allit.hasNext()){
     
      Resource rdfnode = allit.next();
      String uri = rdfnode.getURI();
      //System.out.println(uri);
      if(uri.startsWith("http://purl.org/obo/owl/CHEBI#") || uri.startsWith("http://purl.org/obo/owl/GO#") ||
          uri.startsWith("http://sig.uw.edu/fma#") || uri.startsWith("http://www.reactome.org/biopax")
          || uri.startsWith("http://purl.uniprot.org/uniprot#")){
View Full Code Here

    writer.println( " > " );
        }

    protected void writeRDFStatements( Model model, PrintWriter writer )
        {
    ResIterator rIter = model.listSubjects();
    while (rIter.hasNext()) writeRDFStatements( model, rIter.nextResource(), writer );
    }
View Full Code Here

     * @return {@link OntClass} if there is an already created class for cms object whose identifier got as a
     *         reference, otherwise <code>null</code>.
     */
    public OntClass getOntClassByReference(String reference) throws UnsupportedPolymorphismException,
                                                            ConversionException {
        ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
            reference);
        Resource resource;
        if (it.hasNext()) {
            resource = it.next();
            return resource.as(OntClass.class);

        }
        return null;
    }
View Full Code Here

     *            Unique reference for which the {@link OntProperty} is requested.
     * @return {@link OntProperty} instance if there is a valid one, otherwise <code>null</code>.
     */
    public OntProperty getPropertyByReference(String reference) throws UnsupportedPolymorphismException,
                                                               ConversionException {
        ResIterator it = ontModel.listResourcesWithProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
            reference);
        Resource resource;
        if (it.hasNext()) {
            resource = it.next();
            return resource.as(OntProperty.class);
        }
        return null;
    }
View Full Code Here

TOP

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

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.