예제 #1
0
 @Test
 public void testGetResourceValueOPT3() throws SchemagenOptionsConfigurationException {
   SchemagenOptions so0 = new SchemagenOptions();
   SchemagenOptions so1 = new SchemagenOptions();
   so0.setParent(so1);
   Resource r0 = ResourceFactory.createResource("http://example.org/foo");
   Resource r1 = ResourceFactory.createResource("http://example.org/bar");
   so0.setOption(OPT.ROOT, r0);
   so1.setOption(OPT.ROOT, r1);
   assertEquals(r0, so0.getResource(OPT.ROOT));
 }
예제 #2
0
 @Test
 public void testGetResourceValueOPT1() throws SchemagenOptionsConfigurationException {
   SchemagenOptions so0 = new SchemagenOptions();
   Resource r = ResourceFactory.createResource("http://example.org/foo");
   so0.setOption(OPT.ROOT, r);
   assertEquals(r, so0.getResource(OPT.ROOT));
 }
예제 #3
0
 protected BaseTestCaseResultImpl(String testCaseUri, RLOGLevel severity, String message) {
   this(
       ResourceFactory.createResource(),
       testCaseUri,
       severity,
       message,
       new XSDDateTime(Calendar.getInstance()));
 }
예제 #4
0
 @Test
 public void testHasResourceValueOPT2() throws SchemagenOptionsConfigurationException {
   SchemagenOptions so0 = new SchemagenOptions();
   SchemagenOptions so1 = new SchemagenOptions();
   so0.setParent(so1);
   Resource r = ResourceFactory.createResource("http://example.org/foo");
   so1.setOption(OPT.ROOT, r);
   assertTrue(so0.hasResourceValue(OPT.ROOT));
 }
 @Cacheable("services")
 public Optional<G4Service> getByIdentifier(String identifier) {
   return datasource
       .getOntModel()
       .listIndividuals(DarkData.Visualization)
       .toList()
       .stream()
       .filter(
           i -> i.hasProperty(DCTerms.identifier, ResourceFactory.createTypedLiteral(identifier)))
       .map(G4Service::new)
       .findAny();
 }
예제 #6
0
 @Override
 public String getString(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final String retval = holder.getBaseItem().getString(index);
   checkRead(
       new Triple(
           holder.getBaseItem().asNode(),
           RDF.li(index).asNode(),
           ResourceFactory.createTypedLiteral(retval).asNode()));
   return retval;
 }
예제 #7
0
  /** Test RDF model of a Context. */
  @Test
  public final void testRdfModel() {
    final Context context =
        new Context("My favorite actress is: Natalie Portman. She is very " + "stunning.", 0, 62);
    final Sentence sentence = NullSentence.getInstance();
    final Model model = ModelFactory.createDefaultModel();

    context.addSentence(sentence);

    final String nif = "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#";
    final Map<String, String> prefixes = new HashMap<>();

    prefixes.put("nif", nif);

    final String base = "http://127.0.0.1/stanfordnlp#";

    prefixes.put("local", base);
    prefixes.put("xsd", "http://www.w3.org/2001/XMLSchema#");

    model.setNsPrefixes(prefixes);

    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        RDF.type,
        ResourceFactory.createResource(nif + "String"));
    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        RDF.type,
        ResourceFactory.createResource(nif + "RFC5147String"));
    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        RDF.type,
        ResourceFactory.createResource(nif + "Context"));
    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        ResourceFactory.createProperty(nif + "beginIndex"),
        ResourceFactory.createTypedLiteral("0", XSDDatatype.XSDnonNegativeInteger));
    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        ResourceFactory.createProperty(nif + "endIndex"),
        ResourceFactory.createTypedLiteral("62", XSDDatatype.XSDnonNegativeInteger));
    model.add(
        ResourceFactory.createResource(base + "char=0,62"),
        ResourceFactory.createProperty(nif + "isString"),
        ResourceFactory.createTypedLiteral(
            "My favorite actress is: Natalie Portman. She is very " + "stunning."));

    Assert.assertTrue(
        "Issue to create the model for a Context",
        model.isIsomorphicWith(context.rdfModel("stanfordnlp", NlpProcess.POS)));
  }
예제 #8
0
public class VocabPath {
  public static final Resource start =
      ResourceFactory.createProperty("http://ns.aksw.org/jassa/resource/start");
  public static final Property joinsWith =
      ResourceFactory.createProperty("http://ns.aksw.org/jassa/ontology/joinsWith");
}
예제 #9
0
파일: SHACL.java 프로젝트: AKSW/RDFUnit
 private static Property property(String local) {
   return ResourceFactory.createProperty(namespace, local);
 }
예제 #10
0
파일: SHACL.java 프로젝트: AKSW/RDFUnit
 private static Resource resource(String local) {
   return ResourceFactory.createResource(namespace + local);
 }
예제 #11
0
public class RdfTypeMap
    // extends RdfPopulatorPropertyBase
    extends RdfTypeComplexBase {
  public static final Property entry =
      ResourceFactory.createProperty("http://jsa.aksw.org/ontology/entry");
  public static final Property key =
      ResourceFactory.createProperty("http://jsa.aksw.org/ontology/key");
  public static final Property value =
      ResourceFactory.createProperty("http://jsa.aksw.org/ontology/value");

  public static final Property keyClass =
      ResourceFactory.createProperty("http://jsa.aksw.org/ontology/keyClass");
  public static final Property valueClass =
      ResourceFactory.createProperty("http://jsa.aksw.org/ontology/valueClass");

  // protected MapOps mapOps;
  protected Function<Object, Map> createMapView;

  // , PropertyOps propertyOps, Node predicate, RdfType targetRdfType
  public RdfTypeMap(Function<Object, Map> createMapView) {
    /// super(typeFactory);
    this.createMapView = createMapView;
  }

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

    tmp.out(key.asNode());
    tmp.out(value.asNode());
  }

  @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;
    }
  }

  @Override
  public void populateEntity(
      RdfPersistenceContext persistenceContext,
      Object entity,
      Node subject,
      Graph graph,
      Consumer<Triple> outSink) {
    Model model = ModelFactory.createModelForGraph(graph);
    RDFNode root = ModelUtils.convertGraphNodeToRDFNode(subject, model);

    // <Object, Object>
    Map map = createMapView.apply(entity);

    for (Statement stmt : root.asResource().listProperties(entry).toList()) {
      Resource e = stmt.getObject().asResource();

      Node kNode = e.getProperty(key).getObject().asNode();
      Node vNode = e.getProperty(value).getObject().asNode();

      // TODO: We need to dynamically figure out which entity the node could be
      RdfType rdfType = null;
      Object k =
          persistenceContext.entityFor(
              Object.class, kNode, null); // new TypedNode(rdfType, kNode));
      Object v =
          persistenceContext.entityFor(
              Object.class, vNode, null); // new TypedNode(rdfType, vNode));

      map.put(k, v);
    }
  }

  @Override
  public Class<?> getEntityClass() {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Node getRootNode(Object obj) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Object createJavaObject(Node node, Graph graph) {
    @SuppressWarnings("rawtypes")
    Map result = new HashMap();
    return result;
  }

  @Override
  public boolean hasIdentity() {
    // TODO Auto-generated method stub
    return false;
  }

  //    @Override
  //    public Object createJavaObject(Node node) {
  //        //entityOps.
  //        // TODO Auto-generated method stub
  //        return null;
  //    }

}