@SuppressWarnings("unchecked") @Override public <O extends Graph> O getMetaGraph(Class<O> returnType) { if (!Graph.class.isAssignableFrom(returnType)) throw new IllegalArgumentException( "Only subtypes of " + Graph.class + " are allowed."); return (O) store.getGraph(new IRI(metaGraphId)); }
@SuppressWarnings("unchecked") @Override public <O extends Graph> O getMetaGraph(Class<O> returnType) { if (!Graph.class.isAssignableFrom(returnType)) throw new IllegalArgumentException( "Only subtypes of " + Graph.class + " are allowed."); return (O) store.getGraph(new IRI(metaGraphId)); }
OntologyToTcMapper() { if (store == null) throw new IllegalArgumentException("TcProvider cannot be null"); IRI graphId = new IRI(metaGraphId); try { graph = store.createGraph(graphId); } catch (EntityAlreadyExistsException e) { graph = store.getGraph(graphId); } }
OntologyToTcMapper() { if (store == null) throw new IllegalArgumentException("TcProvider cannot be null"); IRI graphId = new IRI(metaGraphId); try { graph = store.createGraph(graphId); } catch (EntityAlreadyExistsException e) { graph = store.getGraph(graphId); } }
/** * Creates a new input source by querying the supplied triple collection provider for a graph named with * the supplied <code>graphId</code>. The supplied ID will also be set as the graph origin. * * @param graphId * the graph ID. * @throws NullPointerException * if <code>tcProvider</code> is null. * @throws org.apache.clerezza.rdf.core.access.NoSuchEntityException * if no such graph can be found in <code>tcProvider</code>. */ public GraphSource(IRI graphId, TcProvider tcProvider) { this(tcProvider.getGraph(graphId)); bindPhysicalOrigin(Origin.create(graphId)); }
/** * Creates a new input source by querying the supplied triple collection provider for a graph named with * the supplied <code>graphId</code>. The supplied ID will also be set as the graph origin. * * @param graphId * the graph ID. * @throws NullPointerException * if <code>tcProvider</code> is null. * @throws org.apache.clerezza.rdf.core.access.NoSuchEntityException * if no such graph can be found in <code>tcProvider</code>. */ public GraphSource(IRI graphId, TcProvider tcProvider) { this(tcProvider.getGraph(graphId)); bindPhysicalOrigin(Origin.create(graphId)); }
+ supported); Graph tc = store.getGraph(new IRI(identifier)); if (tc == null) return null;
+ supported); Graph tc = store.getGraph(new IRI(identifier)); if (tc == null) return null;
@Test public void testGetTriplesGraph() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); Graph tc = provider.getGraph(graphIRI); assertNotNull(tc); provider.deleteGraph(graphIRI); }
@Test public void testGetTriplesGraph() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); Graph tc = provider.getGraph(graphIRI); assertNotNull(tc); provider.deleteGraph(graphIRI); }
Graph graph = store.getGraph(graphName); IRI ontologyId = null;
Graph graph = store.getGraph(graphName); IRI ontologyId = null;
@Test public void testCreateGraphExtended() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getGraph(graphIRI); assertNotNull(graph); //check that there is no such graph, but only the mgraph boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testGetTriples() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); simpleTcmProvider.createImmutableGraph(uriRefA, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); simpleTcmProvider.createImmutableGraph(uriRefB, mGraph); // add Graphs mGraph = simpleTcmProvider.createGraph(uriRefA1); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); mGraph = simpleTcmProvider.createGraph(uriRefB1); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); // get a ImmutableGraph Graph tripleCollection = simpleTcmProvider.getGraph(uriRefA); // get a Graph Graph tripleCollection2 = simpleTcmProvider.getGraph(uriRefB1); Iterator<Triple> iterator = tripleCollection.iterator(); assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next()); assertFalse(iterator.hasNext()); iterator = tripleCollection2.iterator(); assertEquals(new TripleImpl(uriRefB1, uriRefB1, uriRefB1), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }
@Test public void testGetTriples() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); simpleTcmProvider.createImmutableGraph(uriRefA, mGraph); mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); simpleTcmProvider.createImmutableGraph(uriRefB, mGraph); // add Graphs mGraph = simpleTcmProvider.createGraph(uriRefA1); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); mGraph = simpleTcmProvider.createGraph(uriRefB1); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); // get a ImmutableGraph Graph tripleCollection = simpleTcmProvider.getGraph(uriRefA); // get a Graph Graph tripleCollection2 = simpleTcmProvider.getGraph(uriRefB1); Iterator<Triple> iterator = tripleCollection.iterator(); assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next()); assertFalse(iterator.hasNext()); iterator = tripleCollection2.iterator(); assertEquals(new TripleImpl(uriRefB1, uriRefB1, uriRefB1), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }
@Test public void testCreateGraphExtended() throws Exception { TcProvider provider = getInstance(); Graph graph = provider.createGraph(graphIRI); assertNotNull(graph); //get a new provider and check that graph is there provider = getInstance(); graph = provider.getGraph(graphIRI); assertNotNull(graph); //check that there is no such graph, but only the mgraph boolean expThrown = false; try { ImmutableGraph g = provider.getImmutableGraph(graphIRI); } catch(NoSuchEntityException e) { expThrown = true; } assertTrue(expThrown); provider.deleteGraph(graphIRI); }
@Test public void testDeleteEntity() { TcProvider simpleTcmProvider = getInstance(); Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); ImmutableGraph graph = mGraph.getImmutableGraph(); simpleTcmProvider.createImmutableGraph(uriRefA, graph); simpleTcmProvider.createImmutableGraph(uriRefC, graph); simpleTcmProvider.deleteGraph(uriRefA); try { simpleTcmProvider.getGraph(uriRefA); assertTrue(false); } catch (NoSuchEntityException e) { assertTrue(true); } // Check that graph is still available under uriRefC ImmutableGraph cGraph = simpleTcmProvider.getImmutableGraph(uriRefC); assertNotNull(cGraph); simpleTcmProvider.deleteGraph(uriRefC); }
@Test public void testDeleteEntity() { TcProvider simpleTcmProvider = getInstance(); Graph mGraph = new SimpleGraph(); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); ImmutableGraph graph = mGraph.getImmutableGraph(); simpleTcmProvider.createImmutableGraph(uriRefA, graph); simpleTcmProvider.createImmutableGraph(uriRefC, graph); simpleTcmProvider.deleteGraph(uriRefA); try { simpleTcmProvider.getGraph(uriRefA); assertTrue(false); } catch (NoSuchEntityException e) { assertTrue(true); } // Check that graph is still available under uriRefC ImmutableGraph cGraph = simpleTcmProvider.getImmutableGraph(uriRefC); assertNotNull(cGraph); simpleTcmProvider.deleteGraph(uriRefC); }
@Test public void testGetGraph() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = simpleTcmProvider.createGraph(uriRefA); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); mGraph = simpleTcmProvider.createGraph(uriRefA1); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); mGraph = simpleTcmProvider.createGraph(uriRefB); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefA)); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); mGraph.remove(new TripleImpl(uriRefB, uriRefB, uriRefA)); assertEquals(1, mGraph.size()); mGraph = simpleTcmProvider.createGraph(uriRefB1); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); Graph bGraph = simpleTcmProvider.getGraph(uriRefB); Iterator<Triple> iterator = bGraph.iterator(); assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }
@Test public void testGetGraph() { TcProvider simpleTcmProvider = getInstance(); // add Graphs Graph mGraph = simpleTcmProvider.createGraph(uriRefA); mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA)); mGraph = simpleTcmProvider.createGraph(uriRefA1); mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1)); mGraph = simpleTcmProvider.createGraph(uriRefB); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefA)); mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB)); mGraph.remove(new TripleImpl(uriRefB, uriRefB, uriRefA)); assertEquals(1, mGraph.size()); mGraph = simpleTcmProvider.createGraph(uriRefB1); mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1)); Graph bGraph = simpleTcmProvider.getGraph(uriRefB); Iterator<Triple> iterator = bGraph.iterator(); assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next()); assertFalse(iterator.hasNext()); simpleTcmProvider.deleteGraph(uriRefA); simpleTcmProvider.deleteGraph(uriRefA1); simpleTcmProvider.deleteGraph(uriRefB); simpleTcmProvider.deleteGraph(uriRefB1); }