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

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


                        }
                    } 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) {
View Full Code Here


              }
            } 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) {
            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);
          while(nodes.hasNext()) {
            RDFNode node = nodes.nextNode();
            if(node.isLiteral()) {
              System.out.println("   l " + node.asLiteral().getString());
            } else if(node.isResource()) {
              System.out.println("   r " + node.asResource().getURI());
            }
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

              }
            } 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();
              if (statement.getPredicate().toString().equals("http://xmlns.com/foaf/0.1/name")){
                userName = statement.getObject().toString();
              }
              System.out.println("   triple "+statement.getPredicate()+" - "+statement.getObject());
            }
            for(Property property : propertyAccount) {
              StmtIterator stmtI1 = model.listStatements(resource, property, (RDFNode)null);
            Entity entity = new Entity(userName);
              while(stmtI1.hasNext()) {
                Statement statement = stmtI1.nextStatement();             
                System.out.println("   OnlineAccount "+statement.getObject());
                String accountURL = "";
                String accountUserName = "";
                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());
                    accountUserName = statement2.getObject().toString();
                  }
                  for(Property property2 : propertyAccountProfile) {
                    StmtIterator stmtI2 = model.listStatements(onlineAccount,
                        property2, (RDFNode)null);
                    if(stmtI2.hasNext()){
                      Statement statement2 = stmtI2.nextStatement();
                      System.out.println("      AccountProfile "+statement2.getObject());
                      accountURL = statement2.getObject().toString();
                    }
                  }
                  if(accountUserName.equalsIgnoreCase("not_exist")) {
                    ReputationWiki.notExistantUser.add(userName);
                    continue;
                  }
                  try{
                    Double value = Double.parseDouble(accountUserName);
                    ReputationWiki.userPredefined.add(new Ent_Eva(new Entity(userName),value));
                    continue;
                   
                  }catch (Exception e) {}
                 
                  String domain = ReputationWiki.findDomain(accountURL);
                if(domain == null) {
                  System.out.println("Error: domain is not known from user:"+
                  entity.getUniqueIdentificator()+" and it is discarted: "+ accountURL);
                  continue;
                }
                if(!accountUserName.equals("")){
                  entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
                    new EntityIdentifier(accountUserName,null));
                }
                else{
                  entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
                    new EntityIdentifier(entity.getUniqueIdentificator(),accountURL));
                }
                 
                if(!entity.getIdentificatorInCommunities().isEmpty()) {
                  GlobalModel.addEntity(entity);
                }
                }
              }
            }
          }
      }
    }   
   
    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) {
            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);
          while(nodes.hasNext()) {
            RDFNode node = nodes.nextNode();
            if(node.isLiteral()) {
              System.out.println("   l " + node.asLiteral().getString());
            } else if(node.isResource()) {
              System.out.println("   r " + node.asResource().getURI());
            }
View Full Code Here

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

  }

  public void testListObjects()
  {
    int count = 0;
    NodeIterator iter;
    iter = model.listObjects();
    while (iter.hasNext())
    {
      iter.nextNode();
      count++;
    }
    Assert.assertEquals(num * num, count);
  }
View Full Code Here

  }

  public void testObjectsOfProperty()
  {

    NodeIterator iter;
    final boolean[] object = new boolean[num * num];
    for (int i = 0; i < (num * num); i++)
    {
      object[i] = false;
    }
    iter = model.listObjectsOfProperty(predicate[0]);
    while (iter.hasNext())
    {
      final Literal l = (Literal) iter.nextNode();
      final int i = l.getInt();
      object[i] = true;
    }
    for (int i = 0; i < (num * num); i++)
    {
View Full Code Here

  }

  public void testObjectsOfPropertyAndValue()
  {
    NodeIterator iter;
    final boolean[] object = new boolean[num];
    final Resource subj = model.createResource();
    for (int i = 0; i < num; i++)
    {
      model.addLiteral(subj, RDF.value, i);
      object[i] = false;
    }

    iter = model.listObjectsOfProperty(subj, RDF.value);
    while (iter.hasNext())
    {
      final int i = ((Literal) iter.nextNode()).getInt();
      object[i] = true;
    }
    for (int i = 0; i < (num); i++)
    {
      Assert.assertTrue(object[i]);
View Full Code Here

    super(modelFactory, name);
  }

  protected void checkNumericContent( final Container cont2, final int num )
  {
    final NodeIterator nit = cont2.iterator();
    for (int i = 0; i < num; i += 1)
    {
      Assert.assertEquals(i, ((Literal) nit.nextNode()).getInt());
    }
    Assert.assertFalse(nit.hasNext());
  }
View Full Code Here

  }

  protected void retainOnlySpecified( final Container cont2, final int num,
      final boolean[] retain )
  {
    final NodeIterator nit = cont2.iterator();
    for (int i = 0; i < num; i++)
    {
      nit.nextNode();
      if (retain[i] == false)
      {
        nit.remove();
      }
    }
    Assert.assertFalse(nit.hasNext());
  }
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.