Exemple #1
0
  @Override
  public void exposeShape(ResourceShapeBuilder shapeBuilder) {
    ResourceShapeBuilder tmp = shapeBuilder.out(entry.asNode());

    tmp.out(key.asNode());
    tmp.out(value.asNode());
  }
Exemple #2
0
  @Override
  public void emitTriples(
      RdfEmitterContext emitterContext,
      Object entity,
      Node subject,
      Graph shapeGraph,
      Consumer<Triple> sink) {

    @SuppressWarnings("unchecked")
    Map<? super Object, ? super Object> map = createMapView.apply(entity);

    int i = 1;
    for (Entry<?, ?> e : map.entrySet()) {
      Object k = e.getKey();
      Object v = e.getValue();

      Node eNode = NodeFactory.createURI(subject.getURI() + "-" + i);

      // persistenceContext.
      // persistenceContext.entityFor(new TypedNode(rdfType, node));

      //            Node kNode = null; // emitterContext.getValueNode(entity,
      // propertyName)//RdfPersistenceContextImpl.getOrCreateRootNode(persistenceContext,
      // typeFactory, k);
      //            Node vNode = null;
      // //RdfPersistenceContextImpl.getOrCreateRootNode(persistenceContext, typeFactory, v);

      //            emitterContext.add(k, entity, "key" + i);
      //            emitterContext.add(v, entity, "value" + i);

      // Node keyNode = emitterContext.

      // Node kNode = emitterContext.getValueNode(entity, "key" + i, v);
      // Node vNode = emitterContext.getValueNode(entity, "value" + i, v);

      Node kNode = emitterContext.requestResolution(k);
      Node vNode = emitterContext.requestResolution(v);

      sink.accept(new Triple(subject, entry.asNode(), eNode));
      sink.accept(new Triple(eNode, key.asNode(), kNode));
      sink.accept(new Triple(eNode, value.asNode(), vNode));

      ++i;
    }
  }
Exemple #3
0
  public static void main(String args[]) {

    OntModel m = ModelFactory.createOntologyModel();
    OntDocumentManager dm = m.getDocumentManager();
    dm.addAltEntry(
        "http://www.eswc2006.org/technologies/ontology",
        "file:" + JENA + "src/examples/resources/eswc-2006-09-21.rdf");
    m.read("http://www.eswc2006.org/technologies/ontology");

    // create an empty model
    Model model = ModelFactory.createDefaultModel();

    // create the resource
    Resource johnSmith = model.createResource(personURI);

    // add the property
    johnSmith.addProperty(VCARD.FN, fullName);

    johnSmith.addProperty(
        VCARD.N,
        model.createResource().addProperty(VCARD.Given, "jon").addProperty(VCARD.Family, "Smit"));

    // list the statements in the Model
    StmtIterator iter = model.listStatements();

    // print out the predicate, subject and object of each statement
    while (iter.hasNext()) {
      Statement stmt = iter.nextStatement(); // get next statement
      Resource subject = stmt.getSubject(); // get the subject
      Property predicate = stmt.getPredicate(); // get the predicate
      RDFNode object = stmt.getObject(); // get the object

      System.out.print(subject.toString());
      System.out.print(" " + predicate.toString() + " ");
      if (object instanceof Resource) {
        System.out.print(object.toString());
      } else {
        // object is a literal
        System.out.print(" \"" + object.toString() + "\"");
      }

      System.out.println(" .");
    }
  }
Exemple #4
0
 /**
  * Utility method: answer true iff the enhanced graph contains some triple which has n as subject,
  * p.asNode() as predicate, and any object.
  *
  * @param g an enhanced graph to search for triples
  * @param n some node
  * @param p a property containing a predicate node
  * @return true iff the graph contains (n, p, X) for some X
  */
 public static boolean containsSome(EnhGraph g, Node n, Property p) {
   return g.asGraph().contains(n, p.asNode(), Node.ANY);
 }
 /**
  * Set a configuration paramter for the reasoner. In the case of the this reasoner there are no
  * configuration parameters and this method is simply here to meet the interfaces specification
  *
  * @param parameter the property identifying the parameter to be changed
  * @param value the new value for the parameter, typically this is a wrapped java object like
  *     Boolean or Integer.
  */
 @Override
 public void setParameter(Property parameter, Object value) {
   throw new IllegalParameterException(parameter.toString());
 }