@Override public Set<Namespace> getNamespaces() { Function<Namespace, Namespace> f = identity(); return toSet(rc.getNamespaces(), f); }
protected CloseableIteration<? extends Namespace, SailException> getNamespacesInternal() throws SailException { try { return new RepositoryNamespaceIteration( repoConnection.getNamespaces()); } catch (RepositoryException e) { throw new SailException(e); } }
@Test public void testGetNamespaces() throws Exception { setupNamespaces(); Map<String, String> map = Namespaces.asMap(Iterations.asSet(testCon.getNamespaces())); assertThat(map.size(), is(equalTo(3))); assertThat(map.keySet(), hasItems(EXAMPLE, RDFS_PREFIX, RDF_PREFIX)); assertThat(map.get(EXAMPLE), is(equalTo(EXAMPLE_NS))); assertThat(map.get(RDFS_PREFIX), is(equalTo(RDFS_NS))); assertThat(map.get(RDF_PREFIX), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); }
public void setSesameStatus(RepositoryConnection repositoryConnection) throws RepositoryException { final Repository repository = repositoryConnection.getRepository(); tripleStore.clear(); switch (detailLevel) { case 2: tripleStore.put("statements", String.valueOf(repositoryConnection.size())); tripleStore.put("namespaces", String.valueOf(sizeOf(repositoryConnection.getNamespaces()))); tripleStore.put("contexts", String.valueOf(sizeOf(repositoryConnection.getContextIDs()))); case 1: tripleStore.put("writeable", String.valueOf(repository.isWritable())); break; case 0: default: //nop; } }
public void setSesameStatus(RepositoryConnection repositoryConnection) throws RepositoryException { final Repository repository = repositoryConnection.getRepository(); tripleStore.clear(); switch (detailLevel) { case 2: tripleStore.put("statements", String.valueOf(repositoryConnection.size())); tripleStore.put("namespaces", String.valueOf(sizeOf(repositoryConnection.getNamespaces()))); tripleStore.put("contexts", String.valueOf(sizeOf(repositoryConnection.getContextIDs()))); case 1: tripleStore.put("writeable", String.valueOf(repository.isWritable())); break; case 0: default: //nop; } }
try { conn = repo.getConnection(); CloseableIteration<? extends Namespace, RepositoryException> namespaces = conn.getNamespaces(); result = new ArrayList<Namespace>(); while (namespaces.hasNext()) {
private static void copyNamespacesToModel(RepositoryConnection conn, Model m) throws RepositoryException { RepositoryResult<Namespace> ns = conn.getNamespaces(); while (ns.hasNext()) { m.setNamespace(ns.next()); } }
@Override protected Set<Namespace> doGetNamespaces() { try { final Set<Namespace> namespaces = new HashSet<>(); RepositoryResult<? extends Namespace> iteration; iteration = this.connection.getNamespaces(); try { while (iteration.hasNext()) { namespaces.add(iteration.next()); } } finally { iteration.close(); } return namespaces; } catch (final RepositoryException ex) { throw new ModelException(ex); } }
RepositoryResult<Namespace> memberNamespaces = member.getNamespaces(); try { while (memberNamespaces.hasNext()) {
@GET @Path("/namespaces") @Produces(Namespaces.MIME_TYPE_JSON) public Map<String, String> listKnownNamespaces(@Context UriInfo info) { final PrefixService prefixService = createLocalPrefixService(info); Map<String, String> nss = new HashMap<String, String>(); try { RepositoryConnection con = sesameService.getConnection(); try { con.begin(); for (Namespace ns : iterable(con.getNamespaces())) { nss.put(ns.getPrefix(), ns.getName()); } // commit added con.commit(); } finally { con.close(); } } catch (RepositoryException e) { handleRepositoryException(e,LDPathUtilWebService.class); } for (Map.Entry<String, String> e : prefixService.getMappings().entrySet()) { nss.put(e.getKey(), e.getValue()); } nss.put(FUNCTION_PREFIX, FUNCTION_NAMESPACE); return nss; }
@Override public CloseableIteration<? extends Namespace, SailException> getNamespacesInternal() throws SailException { Map<String, Namespace> namespaces = new HashMap<String, Namespace>(); Set<String> prefixes = new HashSet<String>(); try { for (RepositoryConnection member : members) { RepositoryResult<Namespace> ns = member.getNamespaces(); try { while (ns.hasNext()) { Namespace next = ns.next(); String prefix = next.getPrefix(); if (prefixes.add(prefix)) { namespaces.put(prefix, next); } else if (!next.getName().equals( namespaces.get(prefix).getName())) { namespaces.remove(prefix); } } } finally { ns.close(); } } } catch (RepositoryException e) { throw new SailException(e); } return new CloseableIteratorIteration<Namespace, SailException>( namespaces.values().iterator()); }
@Override public Map<String,String> getNamespaces() { assertModel(); Map<String,String> nsMap = new HashMap<String,String>(); try { RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces(); openrdfMap.enableDuplicateFilter(); List<Namespace> openrdfList = Iterations.asList(openrdfMap); for(Namespace openrdfNamespace : openrdfList) { nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName()); } return nsMap; } catch(RepositoryException e) { throw new ModelRuntimeException(e); } }
public Map<String, String> getNamespaces() { assertModel(); Map<String,String> nsMap = new HashMap<String, String>(); try { RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces(); openrdfMap.enableDuplicateFilter(); List<Namespace> openrdfList = openrdfMap.asList(); for( Namespace openrdfNamespace : openrdfList) { nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName()); } return nsMap; } catch (RepositoryException e) { throw new ModelRuntimeException(e); } }
public Map<String, String> getNamespaces() { Map<String, String> map = new HashMap<String, String>(); try { RepositoryResult<Namespace> spaces = con.getNamespaces(); try { while (spaces.hasNext()) { Namespace ns = spaces.next(); map.put(ns.getPrefix(), ns.getName()); } } finally { spaces.close(); } return map; } catch (RepositoryException e) { throw new ModelException(e); } }
public Map<String, String> getNamespaces() { this.assertModel(); Map<String, String> nsMap = new HashMap<String, String>(); try { RepositoryResult<Namespace> openrdfMap = this.connection .getNamespaces(); openrdfMap.enableDuplicateFilter(); List<Namespace> openrdfList = openrdfMap.asList(); for (Namespace openrdfNamespace : openrdfList) { nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace .getName()); } return nsMap; } catch (RepositoryException e) { throw new ModelRuntimeException(e); } }
@Override public Map<String,String> getNamespaces() { this.assertModel(); Map<String,String> nsMap = new HashMap<String,String>(); try { RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces(); openrdfMap.enableDuplicateFilter(); while (openrdfMap.hasNext()) { Namespace openrdfNamespace = openrdfMap.next(); nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName()); } return nsMap; } catch(RepositoryException e) { throw new ModelRuntimeException(e); } }
@Test public void testGetNamespaces() throws Exception { setupNamespaces(); Map<String, String> map = Namespaces.asMap(Iterations.asSet(testCon.getNamespaces())); assertThat(map.size(), is(equalTo(3))); assertThat(map.keySet(), hasItems(EXAMPLE, RDFS_PREFIX, RDF_PREFIX)); assertThat(map.get(EXAMPLE), is(equalTo(EXAMPLE_NS))); assertThat(map.get(RDFS_PREFIX), is(equalTo(RDFS_NS))); assertThat(map.get(RDF_PREFIX), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); }
final ValueFactory vf = repositoryCon.getValueFactory(); try { CloseableIteration<? extends Namespace, RepositoryException> iter = repositoryCon.getNamespaces();
private Namespaces getNamespaces(RepositoryConnection connection) throws RepositoryException { Namespaces ns = new Namespaces(); RepositoryResult<Namespace> rr = null; try { rr=connection.getNamespaces(); while(rr.hasNext()) { Namespace n=rr.next(); ns.addPrefix(n.getPrefix(), n.getName()); } } finally { closeQuietly(rr,"Could not close results after retrieving namespaces"); } return ns; }
public void startRDF() throws RDFHandlerException { writer.startRDF(); try { if (con == null) { repository = new SailRepository(new MemoryStore()); repository.initialize(); con = repository.getConnection(); } else { CloseableIteration<? extends Namespace, RepositoryException> nsIter = null; try { nsIter = con.getNamespaces(); while (nsIter.hasNext()) { Namespace ns = nsIter.next(); writer.handleNamespace(ns.getPrefix(), ns.getName()); } } finally { if (nsIter != null) { nsIter.close(); } } } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RDFHandlerException(e); } }