/** * List all cache entries in the database, regardless of expiry date. * * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller * @throws SQLException */ public CloseableIteration<KiWiCacheEntry,SQLException> listAll() throws SQLException { PreparedStatement queryExpired = connection.getPreparedStatement("query.entries_all"); final ResultSet result = queryExpired.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiCacheEntry>() { @Override public KiWiCacheEntry apply(ResultSet input) throws SQLException { return constructCacheEntry(result); } }); }
/** * List all cache entries with an expiry date older than the current time. * * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller * @throws SQLException */ public CloseableIteration<KiWiCacheEntry,SQLException> listExpired() throws SQLException { PreparedStatement queryExpired = connection.getPreparedStatement("query.entries_expired"); final ResultSet result = queryExpired.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiCacheEntry>() { @Override public KiWiCacheEntry apply(ResultSet input) throws SQLException { return constructCacheEntry(result); } }); }
/** * List all cache entries with an expiry date older than the current time. * * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller * @throws SQLException */ public CloseableIteration<KiWiCacheEntry,SQLException> listExpired() throws SQLException { PreparedStatement queryExpired = connection.getPreparedStatement("query.entries_expired"); final ResultSet result = queryExpired.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiCacheEntry>() { @Override public KiWiCacheEntry apply(ResultSet input) throws SQLException { return constructCacheEntry(result); } }); }
/** * List all cache entries in the database, regardless of expiry date. * * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller * @throws SQLException */ public CloseableIteration<KiWiCacheEntry,SQLException> listAll() throws SQLException { PreparedStatement queryExpired = connection.getPreparedStatement("query.entries_all"); final ResultSet result = queryExpired.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiCacheEntry>() { @Override public KiWiCacheEntry apply(ResultSet input) throws SQLException { return constructCacheEntry(result); } }); }
public CloseableIteration<KiWiNamespace, SQLException> listNamespaces() throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.namespaces"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiNamespace>() { @Override public KiWiNamespace apply(ResultSet input) throws SQLException { return constructNamespaceFromDatabase(result); } }); }
public CloseableIteration<KiWiNamespace, SQLException> listNamespaces() throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.namespaces"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiNamespace>() { @Override public KiWiNamespace apply(ResultSet input) throws SQLException { return constructNamespaceFromDatabase(result); } }); }
/** * List all contexts used in this triple store. See query.contexts . * @return * @throws SQLException */ public CloseableIteration<KiWiUriResource, SQLException> listResources(String prefix) throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.resources_prefix"); queryContexts.setString(1, prefix + "%"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiUriResource>() { @Override public KiWiUriResource apply(ResultSet row) throws SQLException { return (KiWiUriResource)constructNodeFromDatabase(row); } }); }
/** * List all versions in the database; operates directly on the result set, i.e. the iteration is carried out * lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ private CloseableIteration<Version, SQLException> listVersionsInternal(Date from, Date to) throws SQLException { requireJDBCConnection(); PreparedStatement queryVersions = getPreparedStatement("load.version_between"); synchronized (queryVersions) { queryVersions.clearParameters(); queryVersions.setTimestamp(1, new Timestamp(from.getTime())); queryVersions.setTimestamp(2, new Timestamp(to.getTime())); final ResultSet result = queryVersions.executeQuery(); return new ResultSetIteration<Version>(result, new ResultTransformerFunction<Version>() { @Override public Version apply(ResultSet row) throws SQLException { return constructVersionFromDatabase(result); } }); } }
/** * List all contexts used in this triple store. See query.contexts . * @return * @throws SQLException */ public CloseableIteration<KiWiUriResource, SQLException> listResources(String prefix) throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.resources_prefix"); queryContexts.setString(1, prefix + "%"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiUriResource>() { @Override public KiWiUriResource apply(ResultSet row) throws SQLException { return (KiWiUriResource)constructNodeFromDatabase(row); } }); }
/** * List all versions in the database; operates directly on the result set, i.e. the iteration is carried out * lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ private CloseableIteration<Version, SQLException> listVersionsInternal() throws SQLException { requireJDBCConnection(); PreparedStatement queryVersions = getPreparedStatement("load.versions"); final ResultSet result = queryVersions.executeQuery(); return new ResultSetIteration<Version>(result, new ResultTransformerFunction<Version>() { @Override public Version apply(ResultSet row) throws SQLException { return constructVersionFromDatabase(result); } }); }
/** * List all contexts used in this triple store. See query.contexts . * @return * @throws SQLException */ public CloseableIteration<KiWiResource, SQLException> listResources() throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.resources"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiResource>() { @Override public KiWiResource apply(ResultSet row) throws SQLException { return (KiWiResource)constructNodeFromDatabase(row); } }); }
/** * List all justifications supporting the given triple. * @param tripleId * @return * @throws SQLException */ public CloseableIteration<Justification,SQLException> listJustificationsForTriple(long tripleId) throws SQLException { requireJDBCConnection(); PreparedStatement listForTriple = getPreparedStatement("justifications.load_by_triple"); synchronized (listForTriple) { listForTriple.setLong(1, tripleId); ResultSet result = listForTriple.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<Justification>() { @Override public Justification apply(ResultSet row) throws SQLException { return constructJustificationFromDatabase(row); } }); } }
/** * List all contexts used in this triple store. See query.contexts . * @return * @throws SQLException */ public CloseableIteration<KiWiResource, SQLException> listResources() throws SQLException { requireJDBCConnection(); PreparedStatement queryContexts = getPreparedStatement("query.resources"); final ResultSet result = queryContexts.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiResource>() { @Override public KiWiResource apply(ResultSet row) throws SQLException { return (KiWiResource)constructNodeFromDatabase(row); } }); }
/** * List all triples that are not supported by at least one justification. * @return * @throws SQLException */ public CloseableIteration<KiWiTriple, SQLException> listUnsupportedTriples() throws SQLException { requireJDBCConnection(); PreparedStatement listUnsupported = getPreparedStatement("justifications.list_unsupported"); synchronized (listUnsupported) { ResultSet result = listUnsupported.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiTriple>() { @Override public KiWiTriple apply(ResultSet row) throws SQLException { return constructTripleFromDatabase(row); } }); } }
/** * List all triples that are not supported by at least one justification. * @return * @throws SQLException */ public CloseableIteration<KiWiTriple, SQLException> listUnsupportedTriples() throws SQLException { requireJDBCConnection(); PreparedStatement listUnsupported = getPreparedStatement("justifications.list_unsupported"); synchronized (listUnsupported) { ResultSet result = listUnsupported.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<KiWiTriple>() { @Override public KiWiTriple apply(ResultSet row) throws SQLException { return constructTripleFromDatabase(row); } }); } }
/** * List all justifications supporting the given triple. * @param tripleId * @return * @throws SQLException */ public CloseableIteration<Justification,SQLException> listJustificationsForTriple(long tripleId) throws SQLException { requireJDBCConnection(); PreparedStatement listForTriple = getPreparedStatement("justifications.load_by_triple"); synchronized (listForTriple) { listForTriple.setLong(1, tripleId); ResultSet result = listForTriple.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<Justification>() { @Override public Justification apply(ResultSet row) throws SQLException { return constructJustificationFromDatabase(row); } }); } }
/** * List all currently existing programs in the database. * @return * @throws SQLException */ public CloseableIteration<Program, SQLException> listPrograms() throws SQLException { requireJDBCConnection(); PreparedStatement listPrograms = getPreparedStatement("programs.list"); synchronized (listPrograms) { ResultSet result = listPrograms.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<Program>() { @Override public Program apply(ResultSet row) throws SQLException { try { return constructProgramFromDatabase(row); } catch (ParseException e) { throw new SQLException("error while parsing program rules", e); } } }); } }
/** * Load the rule with the given database ID from the database. * @return * @throws SQLException */ public CloseableIteration<Rule,SQLException> loadRulesByProgram(long programId, final Map<String, String> namespaces) throws SQLException, ParseException { requireJDBCConnection(); PreparedStatement loadRule = getPreparedStatement("rules.load_by_program"); synchronized (loadRule) { loadRule.setLong(1,programId); ResultSet result = loadRule.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<Rule>() { @Override public Rule apply(ResultSet row) throws SQLException { try { return constructRuleFromDatabase(row, namespaces); } catch (ParseException e) { throw new SQLException("error while parsing rule body", e); } } }); } }
/** * List all currently existing programs in the database. * @return * @throws SQLException */ public CloseableIteration<Program, SQLException> listPrograms() throws SQLException { requireJDBCConnection(); PreparedStatement listPrograms = getPreparedStatement("programs.list"); synchronized (listPrograms) { ResultSet result = listPrograms.executeQuery(); return new ResultSetIteration<>(result, new ResultTransformerFunction<Program>() { @Override public Program apply(ResultSet row) throws SQLException { try { return constructProgramFromDatabase(row); } catch (ParseException e) { throw new SQLException("error while parsing program rules", e); } } }); } }
/** * List all versions in the database affecting the given resource as subject; operates directly on the result set, * i.e. the iteration is carried out lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ private CloseableIteration<Version, SQLException> listVersionsInternal(KiWiResource r) throws SQLException { if(r.getId() < 0) { return new EmptyIteration<Version, SQLException>(); } else { requireJDBCConnection(); PreparedStatement queryVersions = getPreparedStatement("load.versions_by_resource"); queryVersions.setLong(1,r.getId()); final ResultSet result = queryVersions.executeQuery(); return new ResultSetIteration<Version>(result, new ResultTransformerFunction<Version>() { @Override public Version apply(ResultSet row) throws SQLException { return constructVersionFromDatabase(result); } }); } }