use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private ColumnDeleteQuery getQuery(Params params, ColumnObserverParser observer, DeleteQuery deleteQuery) {
String columnFamily = observer.fireEntity(deleteQuery.getEntity());
List<String> columns = deleteQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
ColumnCondition condition = null;
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).get();
}
return new DefaultColumnDeleteQuery(columnFamily, condition, columns);
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private ColumnDeleteQuery getQuery(String query, ColumnObserverParser observer) {
DeleteQuery deleteQuery = deleteQueryProvider.apply(query);
String columnFamily = observer.fireEntity(deleteQuery.getEntity());
List<String> columns = deleteQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
ColumnCondition condition = null;
Params params = Params.newParams();
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).get();
}
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return new DefaultColumnDeleteQuery(columnFamily, condition, columns);
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryParser method getQuery.
private DocumentDeleteQuery getQuery(String query, DocumentObserverParser observer) {
DeleteQuery deleteQuery = deleteQueryProvider.apply(query);
String collection = observer.fireEntity(deleteQuery.getEntity());
List<String> documents = deleteQuery.getFields().stream().map(f -> observer.fireField(collection, f)).collect(Collectors.toList());
DocumentCondition condition = null;
Params params = Params.newParams();
if (deleteQuery.getWhere().isPresent()) {
condition = deleteQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, collection)).get();
}
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return new DefaultDocumentDeleteQuery(collection, condition, documents);
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteQueryConverter method apply.
@Override
public List<Vertex> apply(GraphQueryMethod graphQuery) {
DeleteMethodProvider provider = DeleteMethodProvider.get();
DeleteQuery deleteQuery = provider.apply(graphQuery.getMethod(), graphQuery.getEntityName());
ClassMapping mapping = graphQuery.getMapping();
GraphTraversal<Vertex, Vertex> traversal = getGraphTraversal(graphQuery, deleteQuery::getWhere, mapping);
traversal.hasLabel(mapping.getName());
return traversal.toList();
}
use of jakarta.nosql.query.DeleteQuery in project jnosql-diana by eclipse.
the class DeleteByMethodQueryProviderTest method shouldRunQuery29.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "deleteBySalary_Currency" })
public void shouldRunQuery29(String query) {
String entity = "entity";
DeleteQuery deleteQuery = queryProvider.apply(query, entity);
assertNotNull(deleteQuery);
assertEquals(entity, deleteQuery.getEntity());
assertTrue(deleteQuery.getFields().isEmpty());
Optional<Where> where = deleteQuery.getWhere();
assertTrue(where.isPresent());
Condition condition = where.get().getCondition();
Assertions.assertEquals("salary.currency", condition.getName());
}
Aggregations