Package org.apache.clerezza.rdf.core

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


        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);

        provider = getInstance();
        Graph firstGraph = provider.getGraph(name2);
        assertNotNull(firstGraph);

        //check second name is not there
        boolean expThrown = false;

        try {
            Graph g = provider.getGraph(name1);
        } catch(NoSuchEntityException nses) {
            expThrown = true;
        }

        assertTrue(expThrown);
View Full Code Here



    @Test
    public void testGetTriplesGraph() throws Exception {
        TcProvider provider = getInstance();
        Graph graph = provider.createGraph(graphUriRef,
                createTestTripleCollection(createTestTriple()));
        TripleCollection tc = provider.getTriples(graphUriRef);
        assertNotNull(tc);
    }
View Full Code Here

  @Test
  public void serviceExecutionTest() {
    try {
      OpenNLPNERAOService service = new OpenNLPNERAOService();
      Graph graph = service.extractPersons(getClass().getResource("/ner_test_page.html").toURI().toString());
      assertNotNull(graph);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
  }
View Full Code Here

  @Path("post")
  public void postDiscobit(@QueryParam("graph") UriRef graphUri,
      @FormParam("assert") String assertedString,
      @FormParam("revoke") String revokedString) {
    MessageBodyReader<Graph> graphReader = providers.getMessageBodyReader(Graph.class, Graph.class, null,rdfXmlType);
    final Graph assertedGraph;
    final Graph revokedGraph;
    try {
      assertedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0], rdfXmlType, null, new ByteArrayInputStream(assertedString.getBytes()));
      revokedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0], rdfXmlType, null, new ByteArrayInputStream(revokedString.getBytes()));
    } catch (IOException ex) {
      logger.error("reading graph {}", ex);
View Full Code Here

    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
    MGraph mGraph = getMGraph(tcDir);
    mGraph.addAll(triples);
    Graph result = mGraph.getGraph();
   
    graphMap.put(name, result);
    return result;
  }
View Full Code Here

        bundle.getSymbolicName());
  }

  private MGraph getDocumentationMGraph(URL docUrl, String symbolicName) {
    try {
      Graph parsedGraph = parser.parse(docUrl.openStream(),
          SupportedFormat.N_TRIPLE);
      UriRef baseUri = config.getDefaultBaseUri();
      return new SimpleMGraph(new UriMutatorIterator(
          parsedGraph.iterator(), baseUri.getUnicodeString(), symbolicName));
    } catch (IOException ex) {
      logger.warn("Cannot parse documentation at URL: {}", docUrl);
      throw new RuntimeException(ex);
    }
  }
View Full Code Here

      System.out.println("clazz : " + clazz);
      System.out.println("clazz.getMethods().length : " + clazz.getMethods().length);
      //System.out.println("clazz : "+clazz.n);
      System.out.println("processing " + ntFile);
      InputStream in = null;
      Graph documentationGraph = null;
      try {
        in = new FileInputStream(ntFile);
        documentationGraph = parser.parse(in, SupportedFormat.N_TRIPLE);
      } finally {
        in.close();
View Full Code Here

  public void testCreateGraph() {
    TcProvider simpleTcmProvider = getInstance();
    MGraph mGraph = new SimpleMGraph();
    mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));

    Graph createdGraph = simpleTcmProvider.createGraph(uriRefA, mGraph);

    Iterator<Triple> iteratorInput = mGraph.iterator();
    Iterator<Triple> iteratorCreated = createdGraph.iterator();
    assertEquals(iteratorInput.next(), iteratorCreated.next());
    assertFalse(iteratorCreated.hasNext());

    try {
      simpleTcmProvider.createGraph(uriRefA, mGraph);
View Full Code Here

    simpleTcmProvider.createGraph(uriRefB, mGraph);
    mGraph = new SimpleMGraph();
    mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
    simpleTcmProvider.createGraph(uriRefB1, mGraph);

    Graph bGraph = simpleTcmProvider.getGraph(uriRefB);
    Iterator<Triple> iterator = bGraph.iterator();
    assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
    assertFalse(iterator.hasNext());
  }
View Full Code Here

  @Test
  public void testDeleteEntity() {
    TcProvider simpleTcmProvider = getInstance();
    MGraph mGraph = new SimpleMGraph();
    mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
    Graph graph = mGraph.getGraph();
    simpleTcmProvider.createGraph(uriRefA, graph);
    simpleTcmProvider.createGraph(uriRefC, graph);

    simpleTcmProvider.deleteTripleCollection(uriRefA);
    try {
      simpleTcmProvider.getGraph(uriRefA);
      assertTrue(false);
    } catch (NoSuchEntityException e) {
      assertTrue(true);
    }

    // Check that graph is still available under uriRefC
    Graph cGraph = simpleTcmProvider.getGraph(uriRefC);
    assertNotNull(cGraph);
  }
View Full Code Here

TOP

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

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.