Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.UriRef


        }
        return null;
    }

    private UriRef createRandomUriRef() {
        return new UriRef("http://" + UUID.randomUUID().toString());
    }
View Full Code Here


    @Test
    public void testGetSameBNode() throws Exception {
        MGraph graph = getEmptyMGraph();
        BNode bNode = new BNode();
        final UriRef HAS_NAME = new UriRef("http://example.org/ontology/hasName");
        final PlainLiteralImpl name = new PlainLiteralImpl("http://example.org/people/alice");
        final PlainLiteralImpl name2 = new PlainLiteralImpl("http://example.org/people/bob");
        final Triple tripleAlice = new TripleImpl(bNode, HAS_NAME, name);
        final Triple tripleBob = new TripleImpl(bNode, HAS_NAME, name2);
        Assert.assertTrue(graph.add(tripleAlice));
View Full Code Here

        Iterator<Triple> iterator;
        Collection<Triple> resultSet;

        // Find bob
        iterator = graph.filter(null, null,
                new UriRef("http://example.org/people/bob"));
        resultSet= toCollection(iterator);
        Assert.assertEquals(1, resultSet.size());
        Assert.assertTrue(resultSet.contains(tripleBob));

        // Find alice
        iterator = graph.filter(null, null,
                new UriRef("http://example.org/people/alice"));
        resultSet= toCollection(iterator);
        Assert.assertEquals(1, resultSet.size());
        Assert.assertTrue(resultSet.contains(tripleAlice));

        // Find both
View Full Code Here

     * @param object  the object.
     * @throws IllegalArgumentException  If an attribute is <code>null</code>.
     */
    private Triple createTriple(String subject, String predicate,
            String object) {
        return new TripleImpl(new UriRef(subject), new UriRef(predicate),
                new UriRef(object));
    }
View Full Code Here

    public void testGraphDeletion() throws Exception {

        TripleCollection triples = createTestTripleCollection(createTestTriple());

        TcProvider provider = getInstance();
        UriRef name1 = new UriRef("http://myGraph1");
        Graph graph = provider.createGraph(name1, triples);

        UriRef name2 = new UriRef("http://myGraph2");
        Graph secondGraph = provider.createGraph(name2, triples);

        //if we delete graph with name1, the second graph should still be there
        provider.deleteTripleCollection(name1);
View Full Code Here

        assertNotNull(tc);
    }

    private Triple createTestTriple() {
        NonLiteral subject = new BNode() {};
        UriRef predicate = new UriRef("http://test.com/");
        NonLiteral object = new UriRef("http://test.com/myObject");
        return new TripleImpl(subject, predicate, object);
    }
View Full Code Here

        ts.add(t);
        return new SimpleMGraph(ts);
    }

    protected UriRef generateUri(String name) {
        return new UriRef("http://example.org/" + name);
    }
View Full Code Here

        .getAnnotation(SupportedTypes.class);
    if (supportedTypes == null) {
      return;
    }
    for (String typeUriString : supportedTypes.types()) {
      UriRef typeUri = new UriRef(typeUriString);
      typeHandlerMap.put(typeUri, typeHandler);
    }
  }
View Full Code Here

  protected void unbindTypeHandler(Object typeHandler) {
    Iterator<UriRef> keys = typeHandlerMap.keySet().iterator();
    Set<UriRef> toRemove = new HashSet<UriRef>(typeHandlerMap.size());
    synchronized(typeHandlerMap) {
      while (keys.hasNext()) {
        UriRef uriRef = keys.next();
        if(typeHandlerMap.get(uriRef) == typeHandler) {
          toRemove.add(uriRef);
        }
      }
    }
View Full Code Here

    Lock lock = existingNode.writeLock();
    try {
      lock.lock();
      for (FeatureStructure uimaObject : uimaObjects) {
        // create a new node for the current Annotation
        GraphNode annotationNode = new GraphNode(new UriRef(new StringBuilder(ENTITY.Annotation.getUnicodeString()).
                append(uimaObject.hashCode()).toString()), existingNode.getGraph());
        log.info(new StringBuilder("Node created for Type ").append(uimaObject.getType().toString()).toString());

        // set Annotation specific properties for the node
        if (uimaObject instanceof Annotation) {
          Annotation annotation = (Annotation) uimaObject;
          String coveredText = annotation.getCoveredText();
          annotationNode.addPropertyValue(ENTITY.coveredText, coveredText);
          log.info(new StringBuilder("Node wraps Annotation with coveredText:").append(coveredText).toString());
        }

        //XXX : in OpenCalais the type is an URI so it maybe reasonable to put another node here
        annotationNode.addPropertyValue(ENTITY.uimaType, uimaObject.getType().getName());

        /* inspect features of the annotation */
        Type type = uimaObject.getType();
        for (Feature feature : type.getFeatures()) {

          // create a new feature node
          GraphNode featureNode = new GraphNode(new UriRef(new StringBuilder(ENTITY.Feature.getUnicodeString()).
                  append(feature.hashCode() / uimaObject.hashCode()).toString()), annotationNode.getGraph());
          log.info(new StringBuilder("Node created for Feature ").append(feature.getName()).toString());

          // set feature name and value if not null
          featureNode.addPropertyValue(ENTITY.featureName, feature.getName());
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.UriRef

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.