/** * Check whether the uri is ever used as context. * @param conn connection with the repository * @param uri uri of the resource to check * @return true if the uri is ever used as context. */ public static boolean isContext(RepositoryConnection conn, String uri) { return isContext(conn, conn.getValueFactory().createURI(uri)); }
/** * Check whether the uri is ever used as context. * @param conn connection with the repository * @param uri uri of the resource to check * @return true if the uri is ever used as context. */ public static boolean isContext(RepositoryConnection conn, String uri) { return isContext(conn, conn.getValueFactory().createURI(uri)); }
/** * Check whether the {@link Resource} is used in any statement. * Checks if the provided {@link Resource} is used as * <ol> * <li>subject * <li>context * <li>object * <li>predicate (if the resource is a {@link URI}) * </ol> * @param conn {@link ResourceConnection} to check on * @param rsc the {@link Resource} to check * @return true if the {@link Resource} is ever used in a {@link Statement} */ public static boolean isUsed(RepositoryConnection conn, Resource rsc) { if (isSubject(conn, rsc) || isContext(conn, rsc) || isObject(conn, rsc)) return true; return rsc instanceof URI && isPredicate(conn, (URI) rsc); }
/** * Check whether the {@link Resource} is used in any statement. * Checks if the provided {@link Resource} is used as * <ol> * <li>subject * <li>context * <li>object * <li>predicate (if the resource is a {@link URI}) * </ol> * @param conn {@link ResourceConnection} to check on * @param rsc the {@link Resource} to check * @return true if the {@link Resource} is ever used in a {@link Statement} */ public static boolean isUsed(RepositoryConnection conn, Resource rsc) { if (isSubject(conn, rsc) || isContext(conn, rsc) || isObject(conn, rsc)) return true; return rsc instanceof URI && isPredicate(conn, (URI) rsc); }
@Override public URI getContext(String context_uri) { try { RepositoryConnection conn = sesameService.getConnection(); try { conn.begin(); checkConnectionNamespace(conn); if (ResourceUtils.isContext(conn, context_uri)) return conn.getValueFactory().createURI(context_uri); } finally { conn.commit(); conn.close(); } } catch(RepositoryException ex) { handleRepositoryException(ex, ContextServiceImpl.class); } return null; }
@Override public URI getContext(String context_uri) { try { RepositoryConnection conn = sesameService.getConnection(); try { conn.begin(); checkConnectionNamespace(conn); if (ResourceUtils.isContext(conn, context_uri)) return conn.getValueFactory().createURI(context_uri); } finally { conn.commit(); conn.close(); } } catch(RepositoryException ex) { handleRepositoryException(ex, ContextServiceImpl.class); } return null; }