@Override public void removeUserTokens(String userId) { Delete.Where stmt = QueryBuilder.delete().from(KEYSPACE_NAME, ACCESS_TOKEN_TABLE_NAME) .where(QueryBuilder.eq("user_id", userId)); try { session.execute(stmt); } catch (NoHostAvailableException e) { log.error("No host in the %s cluster can be contacted to execute the query.\n", session.getCluster()); } catch (QueryExecutionException e) { log.error("An exception was thrown by Cassandra because it cannot " + "successfully execute the query with the specified consistency level."); } catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); } catch (IllegalStateException e) { log.error("The BoundStatement is not ready."); } }
@Override public void removeAccessToken(String accessToken) { Delete.Where stmt = QueryBuilder.delete().from(KEYSPACE_NAME, ACCESS_TOKEN_TABLE_NAME) .where(QueryBuilder.eq("access_token", accessToken)); try { session.execute(stmt); } catch (NoHostAvailableException e) { log.error("No host in the %s cluster can be contacted to execute the query.\n", session.getCluster()); } catch (QueryExecutionException e) { log.error("An exception was thrown by Cassandra because it cannot " + "successfully execute the query with the specified consistency level."); } catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); } catch (IllegalStateException e) { log.error("The BoundStatement is not ready."); } }
@Override public boolean deleteScope(String scopeName) { Delete.Where stmt = QueryBuilder.delete().from(KEYSPACE_NAME, SCOPE_TABLE_NAME) .where(QueryBuilder.eq("scope", scopeName)); try { session.execute(stmt); } catch (NoHostAvailableException e) { log.error("No host in the %s cluster can be contacted to execute the query.\n", session.getCluster()); return false; } catch (QueryExecutionException e) { log.error("An exception was thrown by Cassandra because it cannot " + "successfully execute the query with the specified consistency level."); return false; } catch (QueryValidationException e) { log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n", stmt.getQueryString())); return false; } catch (IllegalStateException e) { log.error("The BoundStatement is not ready."); return false; } return true; }
private static String deleteSQL(final String table) { return QueryBuilder.delete().from(table).where(eq(ID, raw("?"))).getQueryString(); }
private static String deleteSQL(final String table) { return QueryBuilder.delete().from(table).where(eq(ID, raw("?"))).getQueryString(); }
/** * @return cql query statement to delete a task_id to workflow_id mapping from the "task_lookup" table */ public String getDeleteTaskLookupStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_TASK_LOOKUP) .where(eq(TASK_ID_KEY, bindMarker())) .getQueryString(); }
/** * @return cql query statement to delete a workflow from the "workflows" table */ public String getDeleteWorkflowStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_WORKFLOWS) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, bindMarker())) .getQueryString(); }
/** * @return cql query statement to delete a task from the "workflows" table */ public String getDeleteTaskStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_WORKFLOWS) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, bindMarker())) .and(eq(ENTITY_KEY, ENTITY_TYPE_TASK)) .and(eq(TASK_ID_KEY, bindMarker())) .getQueryString(); } }