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

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


  }
 
  public void printNumericScales(Model model) throws Exception {
    Resource numericScale = ResourceFactory.
        createResource(riNamespace + "NumericScale");
    ResIterator iters = model.listSubjectsWithProperty(
        RDF.type,numericScale);
    if (iters.hasNext()) {
        System.out.println("The database contains subjects" +
            " of type NumericScale:");
        while (iters.hasNext()) {
            Resource resource = iters.nextResource();
            System.out.println("  " + resource.getLocalName());
            NumericScale numScaInstance =
              getNumericScale(model,resource);
            System.out.println("     name:" +
                numScaInstance.getName());
View Full Code Here


  }
 
  public void printScales(Model model) throws Exception {
    Resource scale = ResourceFactory.
        createResource(riNamespace + "Scale");
    ResIterator iters = model.listSubjectsWithProperty(
        RDF.type,scale);
    if (iters.hasNext()) {
        System.out.println("The database contains subjects" +
            " of type scale:");
        while (iters.hasNext()) {
            Resource resource = iters.nextResource();
            System.out.println("  " + resource.getLocalName());
            Scale scaleInstance =
              getScale(model,resource,null);
            System.out.println("     name:" +
                scaleInstance.getName());                     
View Full Code Here

  // http://www.w3.org/TR/void/#dublin-core

  private static Set<Resource> generatePartitions(Model m, Resource type,
      Property p) {
    Set<Resource> partitions = new HashSet<Resource>();
    ResIterator classIt = m.listResourcesWithProperty(RDF.type, type);
    while (classIt.hasNext()) {
      Resource classMap = classIt.next();
      StmtIterator pIt = classMap.listProperties(p);
      while (pIt.hasNext()) {
        partitions.add((Resource) pIt.next().getObject());
      }
    }
View Full Code Here

    try {
      Model model = WorksheetR2RMLJenaModelParser.loadSourceModelIntoJenaModel(modelURL);
      Property rdfTypeProp = model.getProperty(Uris.RDF_TYPE_URI);
      Property baseURIProp = model.getProperty(Uris.KM_HAS_BASEURI);
      RDFNode node = model.getResource(Uris.KM_R2RML_MAPPING_URI);
      ResIterator res = model.listResourcesWithProperty(rdfTypeProp, node);
      List<Resource> resList = res.toList();
      for(Resource r: resList)
      {
        if (r.hasProperty(baseURIProp)) {
          baseURI = r.getProperty(baseURIProp).asTriple().getObject().toString();
          baseURI = baseURI.replace("\"", "");
View Full Code Here

        return model;
    }
  private Resource getMappingResourceFromSourceName() throws KarmaException {
    Property sourceNameProp = model.getProperty(Uris.KM_SOURCE_NAME_URI);
    RDFNode node = model.createLiteral(id.getName());
    ResIterator res = model.listResourcesWithProperty(sourceNameProp, node);
    List<Resource> resList = res.toList();
   
    if (resList.size() > 1) {
      throw new KarmaException("More than one resource exists with source name: " + id.getName());
    } else if (resList.size() == 1) {
      return resList.get(0);
    } else {
      //If we didnt find the sourceName in the model, maybe it is a different source with the
      //same schema.
      //Maybe we need to substitute the sourceName in the model with this one
      NodeIterator sourceObjectIter = model.listObjectsOfProperty(sourceNameProp);
      List<RDFNode> sourceObjects = sourceObjectIter.toList();
     
      if(sourceObjects.size() > 1) {
        throw new KarmaException("More than one resource exists with source name: " + id.getName());
      } else if(sourceObjects.size() == 1) {
        RDFNode prevSourceObject = sourceObjects.get(0);
       
        //We got the previous source object, now get the Subject Node for this
        ResIterator prevSourceSubjectsIter = model.listResourcesWithProperty(sourceNameProp, prevSourceObject);
        List<Resource> prevSourceSubjects = prevSourceSubjectsIter.toList();
       
        if (prevSourceSubjects.size() == 1) {
          Resource subject = prevSourceSubjects.get(0);
          model.remove(subject, sourceNameProp, prevSourceObject);
          model.add(subject, sourceNameProp, node);
View Full Code Here

  private void calculateColumnNodesCoveredByBlankNodes(KR2RMLMapping kr2rmlMapping, List<Resource> subjectMapResources) throws JSONException, KarmaException {
    Property termTypeProp = model.getProperty(Uris.RR_TERM_TYPE_URI);
    Resource blankNodeRes = model.getResource(Uris.RR_BLANK_NODE_URI);
    Property kmBnodePrefixProp = model.getProperty(Uris.KM_BLANK_NODE_PREFIX_URI);
    ResIterator blankNodeSubjMapItr = model.listResourcesWithProperty(termTypeProp, blankNodeRes);
   
    for (Resource subjMapRes:subjectMapResources) {
     
      if (model.contains(subjMapRes, termTypeProp, blankNodeRes)) {
        List<String> columnsCovered = new ArrayList<String>();
        Resource blankNodeSubjRes = blankNodeSubjMapItr.next();
       
        SubjectMap subjMap = kr2rmlMapping.getSubjectMapIndex().get(blankNodeSubjRes.getId().getLabelString());
        subjMap.setAsBlankNode(true);
        NodeIterator bnodePrefixItr = model.listObjectsOfProperty(blankNodeSubjRes, kmBnodePrefixProp);
        while (bnodePrefixItr.hasNext()) {
View Full Code Here

    }
   
    Property rdfType = this.ontHandler.getOntModel().createProperty(Uris.RDF_TYPE_URI);
    Resource classNode = this.ontHandler.getOntModel().createResource(Uris.RDFS_CLASS_URI);
    ResIterator itr = ontHandler.getOntModel().listSubjectsWithProperty(rdfType, classNode);
   
    while (itr.hasNext()) {
     
      Resource r = itr.next();
     
      if (!r.isURIResource())
        continue;
     
      if (!classes.containsKey(r.getURI()))
View Full Code Here

      StringWriter test = new StringWriter();
      Model model = WorksheetR2RMLJenaModelParser.loadSourceModelIntoJenaModel(url);
      Property rdfTypeProp = model.getProperty(Uris.RDF_TYPE_URI);

      RDFNode node = model.getResource(Uris.KM_R2RML_MAPPING_URI);
      ResIterator res = model.listResourcesWithProperty(rdfTypeProp, node);
      List<Resource> resList = res.toList();
      for(Resource r: resList)
      {
        model.add(r, model.getProperty(Uris.OWL_SAMEAS_URI), model.getResource(url.toString()));
      }
      model.write(test,"TTL");
View Full Code Here

    Model model = ModelFactory.createDefaultModel();
    URL url = SecurityExample.class.getClassLoader().getResource(
        "org/apache/jena/security/example/example.ttl");
    model.read(url.toExternalForm());
    ResIterator ri = model.listSubjectsWithProperty(RDF.type, msgType);
    System.out.println("All the messages");
    while (ri.hasNext()) {
      Resource msg = ri.next();
      Statement to = msg.getProperty(pTo);
      Statement from = msg.getProperty(pFrom);
      Statement subj = msg.getProperty(pSubj);
      System.out.println(String.format("%s to: %s  from: %s  subj: %s",
          msg, to.getObject(), from.getObject(), subj.getObject()));
    }
    System.out.println();

    ExampleEvaluator evaluator = new ExampleEvaluator(model);
    model = Factory.getInstance(evaluator,
        "http://example.com/SecuredModel", model);
    for (String userName : names) {
      evaluator.setPrincipal(userName);

      System.out.println("Messages " + userName + " can manipulate");
      ri = model.listSubjectsWithProperty(RDF.type, msgType);
      while (ri.hasNext()) {
        Resource msg = ri.next();
        Statement to = msg.getProperty(pTo);
        Statement from = msg.getProperty(pFrom);
        Statement subj = msg.getProperty(pSubj);
        System.out.println(String.format(
            "%s to: %s  from: %s  subj: %s", msg, to.getObject(),
            from.getObject(), subj.getObject()));
      }
      ri.close();
      for (String name : names)
      {
        System.out.println( String.format( "%s messages to %s", model.listSubjectsWithProperty( pTo, name ).toList().size(), name ) );
      }
      System.out.println();
View Full Code Here

        return x ;
    }
   
    private static List<Resource> getByType(Resource type, Model m)
    {
        ResIterator rIter = m.listSubjectsWithProperty(RDF.type, type) ;
        return Iter.toList(rIter) ;
    }
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.