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

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


        Resource collectingSystem = ResourceFactory.createResource(
            riNamespace + "CollectingSystem");
        Resource community = ResourceFactory.createResource(
            riNamespace + "Community");
       
        Property identifier = ResourceFactory.createProperty(
            riNamespace + "identifier");
        Property hasDimension = ResourceFactory.createProperty(
            riNamespace + "hasDimension");
        Property hasScale = ResourceFactory.createProperty(
            riNamespace + "hasScale");
        Property name = ResourceFactory.createProperty(
            riNamespace + "name");
        Property uriFormat = ResourceFactory.createProperty(
            riNamespace + "uriFormat");
        Property homePage = ResourceFactory.createProperty(
            riNamespace + "homePage");
        Property hasCategory = ResourceFactory.createProperty(
            riNamespace + "hasCategory");
        Property hasReputationModel = ResourceFactory.createProperty(
            riNamespace + "hasReputationModel");
        Property reputationModule = ResourceFactory.createProperty(
            riNamespace + "reputationModule");
        Property mapsMetric = ResourceFactory.createProperty(
            riNamespace + "mapsMetric");
        Property importedCommunity = ResourceFactory.createProperty(
            riNamespace + "importedCommunity");
        Property importedMetric = ResourceFactory.createProperty(
            riNamespace + "importedMetric");
        Property collectsReputationBy = ResourceFactory.createProperty(
            riNamespace + "collectsReputationBy");
        Property metricTransformation = ResourceFactory.createProperty(
            riNamespace + "metricTransformation");
        Property trust = ResourceFactory.createProperty(
            riNamespace + "trust");
        Property importsFrom = ResourceFactory.createProperty(
            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();
            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");
            }
          }
        /* homePage */
                stmtI1 = model.listStatements(resource, homePage, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    homePage:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    homePage resource " +
                  "impossible:"+statement.getObject());             
            } else {
              System.out.println("    homePage no literal no resource");
            }
          }
        /* hasCategory */
        stmtI1 = model.listStatements(resource, hasCategory, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    hasCategory impossible:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    hasCategory resource:"
                  +statement.getObject());
              Resource catResource = statement.getObject().asResource();                 
              StmtIterator stmtI2 = model.listStatements(catResource,
                   (Property)null, (RDFNode)null);
               while(stmtI2.hasNext()) {
                Statement statement2 = stmtI2.nextStatement();
                System.out.println("      "+statement2.getPredicate().getLocalName()
                    +" "+statement2.getObject());
               }
            } else {
              System.out.println("    hasCategory no literal no resource");
            }
          }
        /* hasReputationModel */
        stmtI1 = model.listStatements(resource, hasReputationModel, (RDFNode)null);
        while(stmtI1.hasNext()) {
            Statement statement = stmtI1.nextStatement();
            if(statement.getObject().isLiteral()) {
              System.out.println("    hasReputationModel impossible:"+statement.getObject());             
            } else if(statement.getObject().isResource()) {
              System.out.println("    hasReputationModel resource:"
                  +statement.getObject());
              Resource repResource = statement.getObject().asResource();                 
              StmtIterator stmtI2 = model.listStatements(repResource,
                   (Property)null, (RDFNode)null);
               while(stmtI2.hasNext()) {
                Statement statement2 = stmtI2.nextStatement();
                if(reputationModule.getURI().equalsIgnoreCase(
                    statement2.getPredicate().getURI())) {
                  System.out.println("      "+reputationModule.getURI()+" property "
                      +statement2.getObject());
                  Resource modResource = statement2.getObject().asResource();                 
                  StmtIterator stmtI3 = model.listStatements(modResource,
                       (Property)null, (RDFNode)null);
                  while(stmtI3.hasNext()) {
                    Statement statement3 = stmtI3.nextStatement();
                    if(statement3.getObject().isLiteral()) {
                      System.out.println("         "+statement3.getPredicate().getLocalName()
                          +":"+statement3.getObject());             
                    } else if(statement3.getObject().isResource()) {
                      System.out.println("         "+statement3.getPredicate().getLocalName()
                          +" resource:"+statement3.getObject());
                      Resource anyResource = statement3.getObject().asResource();                 
                      StmtIterator stmtI4 = model.listStatements(anyResource,
                           (Property)null, (RDFNode)null);
                      if(mapsMetric.getURI().equalsIgnoreCase(
                          statement3.getPredicate().getURI())) {
                       
                      } else if(importsFrom.getURI().equalsIgnoreCase(
                          statement3.getPredicate().getURI())) {
                        while(stmtI4.hasNext()) {
                          Statement statement4 = stmtI4.nextStatement();
                          if(importedCommunity.getURI().equals(statement4.getPredicate().getURI())) {
                            if(statement4.getObject().isLiteral()) {
View Full Code Here


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

   
    private static Model makeData()
    {
        Model model = ModelFactory.createDefaultModel() ;
        Resource r = model.createResource(NS+"r") ;
        Property p1 = model.createProperty(NS+"p1") ;
        Property p2 = model.createProperty(NS+"p2") ;
        model.add(r, p1, "xyz") ;
        model.add(r, p2, "abc") ;
        return model ;
    }
View Full Code Here

        String BASE = "http://example/" ;
        Model model = ModelFactory.createDefaultModel() ;
        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) ;
View Full Code Here

        if (graph.isEmpty()) {
            final Resource product1 = model.createResource(
                    iriFactory.construct( MY_NS +"product/1" )
                        .toString() );

            final Property hasName = model.createProperty( MY_NS, "#hasName");
            final Statement stmt = model.createStatement(
                    product1, hasName, model.createLiteral("Beach Ball","en") );
            out.println("Statement = " + stmt);

            model.add(stmt);
View Full Code Here

      QuerySolution s = results.nextSolution();
      Resource in = s.getResource("in");
      Resource out = s.getResource("out");
      Resource test = s.getResource("test");
     
      Property approval = m.createProperty(
          TestSchema, "approval");
      if (!test.hasProperty(approval))
        System.out.println("#"+test.getLocalName());
      if (!in.equals(last)) {
        one = new WDSingleTest(in);
View Full Code Here

        final Triple remove = GraphTestBase.triple(case1[1]);
        final Node s = remove.getSubject(), p = remove.getPredicate(), o = remove
            .getObject();
        final Resource S = (Resource) (s.equals(Node.ANY) ? null : mc
            .getRDFNode(s));
        final Property P = ((p.equals(Node.ANY) ? null : mc.getRDFNode(
            p).as(Property.class)));
        final RDFNode O = o.equals(Node.ANY) ? null : mc.getRDFNode(o);
        final Model expected = ModelHelper.modelWithStatements(this,
            case1[2]);
        content.removeAll(S, P, O);
View Full Code Here

    final Resource r = model
        .createResource("http://www.electric-hedgehog.net/a-o-s.html");
    Assert.assertFalse("the Resouce should not be null", r == null);
    Assert.assertTrue("the Resource can be a Property",
        r.canAs(Property.class));
    final Property p = r.as(Property.class);
    Assert.assertFalse("the Property should not be null", p == null);
    Assert.assertFalse("the Resource and Property should not be identical",
        r == p);
  }
View Full Code Here

  }

  public void testGetPropertyOneArg()
  {
    final String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a" + 130;
    final Property p = model.getProperty(uri);
    Assert.assertEquals(uri, p.getURI());
  }
View Full Code Here

  }

  public void testGetPropertyTwoArgs()
  {
    final String ns = "http://aldabaran.hpl.hp.com/rdf/test4/a" + 140 + "/";
    final Property p = model.getProperty(ns, "foo");
    Assert.assertEquals(ns + "foo", p.getURI());
  }
View Full Code Here

TOP

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

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.