use of jakarta.nosql.QueryException in project jnosql-diana by eclipse.
the class UpdateQueryParser method query.
Stream<ColumnEntity> query(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
UpdateQuery updateQuery = updateQueryProvider.apply(query);
Params params = Params.newParams();
ColumnEntity entity = getEntity(params, updateQuery, observer);
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return Stream.of(manager.update(entity));
}
use of jakarta.nosql.QueryException in project jnosql-diana by eclipse.
the class InsertQueryParser method query.
Stream<ColumnEntity> query(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
InsertQuery insertQuery = insertQueryProvider.apply(query);
String columnFamily = insertQuery.getEntity();
Params params = Params.newParams();
ColumnEntity entity = getEntity(insertQuery, columnFamily, params, observer);
Optional<Duration> ttl = insertQuery.getTtl();
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
if (ttl.isPresent()) {
return Stream.of(manager.insert(entity, ttl.get()));
} else {
return Stream.of(manager.insert(entity));
}
}
use of jakarta.nosql.QueryException in project jnosql-diana by eclipse.
the class ConditionQueryParser method getEntity.
protected ColumnEntity getEntity(ConditionQuerySupplier query, String columnFamily, Params params, ColumnObserverParser observer) {
ColumnEntity entity = ColumnEntity.of(columnFamily);
if (query.useJSONCondition()) {
JSONQueryValue jsonValue = query.getValue().orElseThrow(() -> new QueryException("It is an invalid state of" + " either Update or Insert."));
List<Column> columns = JsonObjects.getColumns(jsonValue.get());
entity.addAll(columns);
return entity;
}
query.getConditions().stream().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).map(ColumnCondition::getColumn).forEach(entity::add);
return entity;
}
use of jakarta.nosql.QueryException in project jnosql-diana by eclipse.
the class DelQueryParser method query.
Stream<Value> query(String query, BucketManager manager) {
DelQuery delQuery = provider.apply(query);
Params params = Params.newParams();
List<Value> values = delQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
List<Object> keys = values.stream().map(Value::get).collect(toList());
manager.delete(keys);
return Stream.empty();
}
use of jakarta.nosql.QueryException in project jnosql-diana by eclipse.
the class PutQueryParser method query.
Stream<Value> query(String query, BucketManager manager) {
PutQuery putQuery = provider.apply(query);
Params params = Params.newParams();
Value key = Values.getValue(putQuery.getKey(), params);
Value value = Values.getValue(putQuery.getValue(), params);
Optional<Duration> ttl = putQuery.getTtl();
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
KeyValueEntity entity = KeyValueEntity.of(key.get(), value.get());
if (ttl.isPresent()) {
manager.put(entity, ttl.get());
} else {
manager.put(entity);
}
return Stream.empty();
}
Aggregations