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

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


     }

     public void applyStatement (Statement stmt, ConceptTO conceptTO){
         Resource  subject   = stmt.getSubject();
         Property  predicate = stmt.getPredicate();
         RDFNode   object    = stmt.getObject();
     }
View Full Code Here


    public static String[] fetchQuerySolutionToSimpleArray(QuerySolution []solutions,String field) {
        LinkedList results = new LinkedList();
        if(solutions != null){
            int size = solutions.length;
            for(int i = 0; i< size; i++){
                RDFNode node = solutions[i].get(field);
                String value= (node==null)?"": node.isLiteral() ?  solutions[i].getLiteral(field).getString(): node.toString();
                //Do not repeat values
                if(!results.contains(value)) results.add(value);
            }
          }
        return (String[]) results.toArray(new String[results.size()]);
View Full Code Here

              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());
            }
          }         
        }
    } else {
        System.out.println("No subject with RDF.type were found in the database");
View Full Code Here

        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

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

              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());
            }
          }         
        }
    } else {
        System.out.println("No subject with RDF.type were found in the database");
View Full Code Here

        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

        Literal typedLiteral = model.createTypedLiteral("<elem>foo</elem>", XMLLiteralType.theXMLLiteralType);
        model.add(RDFS.Class, RDFS.label, typedLiteral);
        Assert.assertEquals(1, mGraph.size());
        StmtIterator iter = model.listStatements(RDFS.Class, RDFS.label, (Resource)null);
        Assert.assertTrue(iter.hasNext());
        RDFNode gotObject = iter.nextStatement().getObject();
        Assert.assertEquals(typedLiteral, gotObject);
    }
View Full Code Here

            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here

        model.setNsPrefix("", BASE) ;
        Resource r1 = model.createResource(BASE+"r1") ;
        Resource r2 = model.createResource(BASE+"r2") ;
        Property p1 = model.createProperty(BASE+"p") ;
        Property p2 = model.createProperty(BASE+"p2") ;
        RDFNode v1 = model.createTypedLiteral("1", XSDDatatype.XSDinteger) ;
        RDFNode v2 = model.createTypedLiteral("2", XSDDatatype.XSDinteger) ;
       
        r1.addProperty(p1, v1).addProperty(p1, v2) ;
        r1.addProperty(p2, v1).addProperty(p2, v2) ;
        r2.addProperty(p1, v1).addProperty(p1, v2) ;
       
View Full Code Here

TOP

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

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.