Search in sources :

Example 1 with ColumnObserverParser

use of jakarta.nosql.column.ColumnObserverParser 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);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) DeleteQueryConverter(jakarta.nosql.column.DeleteQueryConverter) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) ColumnCondition(jakarta.nosql.column.ColumnCondition) Collectors(java.util.stream.Collectors) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) DeleteQuery(jakarta.nosql.query.DeleteQuery) List(java.util.List) DeleteQueryProvider(jakarta.nosql.query.DeleteQuery.DeleteQueryProvider) Stream(java.util.stream.Stream) QueryException(jakarta.nosql.QueryException) Objects.requireNonNull(java.util.Objects.requireNonNull) ColumnDeleteQueryParams(jakarta.nosql.column.ColumnDeleteQueryParams) ColumnPreparedStatement(jakarta.nosql.column.ColumnPreparedStatement) ColumnObserverParser(jakarta.nosql.column.ColumnObserverParser) Params(jakarta.nosql.Params) ColumnCondition(jakarta.nosql.column.ColumnCondition)

Example 2 with ColumnObserverParser

use of jakarta.nosql.column.ColumnObserverParser 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);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) DeleteQueryConverter(jakarta.nosql.column.DeleteQueryConverter) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) ColumnCondition(jakarta.nosql.column.ColumnCondition) Collectors(java.util.stream.Collectors) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) DeleteQuery(jakarta.nosql.query.DeleteQuery) List(java.util.List) DeleteQueryProvider(jakarta.nosql.query.DeleteQuery.DeleteQueryProvider) Stream(java.util.stream.Stream) QueryException(jakarta.nosql.QueryException) Objects.requireNonNull(java.util.Objects.requireNonNull) ColumnDeleteQueryParams(jakarta.nosql.column.ColumnDeleteQueryParams) ColumnPreparedStatement(jakarta.nosql.column.ColumnPreparedStatement) ColumnObserverParser(jakarta.nosql.column.ColumnObserverParser) Params(jakarta.nosql.Params) QueryException(jakarta.nosql.QueryException) ColumnDeleteQueryParams(jakarta.nosql.column.ColumnDeleteQueryParams) Params(jakarta.nosql.Params) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) DeleteQuery(jakarta.nosql.query.DeleteQuery) ColumnCondition(jakarta.nosql.column.ColumnCondition)

Example 3 with ColumnObserverParser

use of jakarta.nosql.column.ColumnObserverParser in project jnosql-diana by eclipse.

the class SelectQueryParser method getColumnQuery.

private ColumnQuery getColumnQuery(Params params, SelectQuery selectQuery, ColumnObserverParser observer) {
    String columnFamily = observer.fireEntity(selectQuery.getEntity());
    long limit = selectQuery.getLimit();
    long skip = selectQuery.getSkip();
    List<String> columns = selectQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
    List<Sort> sorts = selectQuery.getOrderBy().stream().map(s -> toSort(s, observer, columnFamily)).collect(toList());
    ColumnCondition condition = null;
    if (selectQuery.getWhere().isPresent()) {
        condition = selectQuery.getWhere().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).get();
    }
    return new DefaultColumnQuery(limit, skip, columnFamily, columns, sorts, condition);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) SelectQuery(jakarta.nosql.query.SelectQuery) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) ColumnQueryParams(jakarta.nosql.column.ColumnQueryParams) ColumnCondition(jakarta.nosql.column.ColumnCondition) Collectors(java.util.stream.Collectors) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) SelectQueryConverter(jakarta.nosql.column.SelectQueryConverter) Objects(java.util.Objects) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) QueryException(jakarta.nosql.QueryException) SelectQueryProvider(jakarta.nosql.query.SelectQuery.SelectQueryProvider) ColumnPreparedStatement(jakarta.nosql.column.ColumnPreparedStatement) ColumnQuery(jakarta.nosql.column.ColumnQuery) Sort(jakarta.nosql.Sort) ColumnObserverParser(jakarta.nosql.column.ColumnObserverParser) Params(jakarta.nosql.Params) Sort(jakarta.nosql.Sort) ColumnCondition(jakarta.nosql.column.ColumnCondition)

Example 4 with ColumnObserverParser

use of jakarta.nosql.column.ColumnObserverParser in project jnosql-diana by eclipse.

the class SelectQueryParser method getColumnQuery.

private ColumnQuery getColumnQuery(String query, ColumnObserverParser observer) {
    SelectQuery selectQuery = selectQueryProvider.apply(query);
    String columnFamily = observer.fireEntity(selectQuery.getEntity());
    long limit = selectQuery.getLimit();
    long skip = selectQuery.getSkip();
    List<String> columns = selectQuery.getFields().stream().map(f -> observer.fireField(columnFamily, f)).collect(Collectors.toList());
    List<Sort> sorts = selectQuery.getOrderBy().stream().map(s -> toSort(s, observer, columnFamily)).collect(toList());
    ColumnCondition condition = null;
    Params params = Params.newParams();
    if (selectQuery.getWhere().isPresent()) {
        condition = selectQuery.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 DefaultColumnQuery(limit, skip, columnFamily, columns, sorts, condition);
}
Also used : SelectQuery(jakarta.nosql.query.SelectQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) SelectQuery(jakarta.nosql.query.SelectQuery) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) ColumnQueryParams(jakarta.nosql.column.ColumnQueryParams) ColumnCondition(jakarta.nosql.column.ColumnCondition) Collectors(java.util.stream.Collectors) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) SelectQueryConverter(jakarta.nosql.column.SelectQueryConverter) Objects(java.util.Objects) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) QueryException(jakarta.nosql.QueryException) SelectQueryProvider(jakarta.nosql.query.SelectQuery.SelectQueryProvider) ColumnPreparedStatement(jakarta.nosql.column.ColumnPreparedStatement) ColumnQuery(jakarta.nosql.column.ColumnQuery) Sort(jakarta.nosql.Sort) ColumnObserverParser(jakarta.nosql.column.ColumnObserverParser) Params(jakarta.nosql.Params) QueryException(jakarta.nosql.QueryException) Sort(jakarta.nosql.Sort) ColumnQueryParams(jakarta.nosql.column.ColumnQueryParams) Params(jakarta.nosql.Params) ColumnCondition(jakarta.nosql.column.ColumnCondition)

Aggregations

Params (jakarta.nosql.Params)4 QueryException (jakarta.nosql.QueryException)4 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)4 ColumnCondition (jakarta.nosql.column.ColumnCondition)4 ColumnEntity (jakarta.nosql.column.ColumnEntity)4 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)4 ColumnObserverParser (jakarta.nosql.column.ColumnObserverParser)4 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Stream (java.util.stream.Stream)4 Sort (jakarta.nosql.Sort)2 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)2 ColumnDeleteQueryParams (jakarta.nosql.column.ColumnDeleteQueryParams)2 ColumnQuery (jakarta.nosql.column.ColumnQuery)2 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)2 DeleteQueryConverter (jakarta.nosql.column.DeleteQueryConverter)2 SelectQueryConverter (jakarta.nosql.column.SelectQueryConverter)2 DeleteQuery (jakarta.nosql.query.DeleteQuery)2 DeleteQueryProvider (jakarta.nosql.query.DeleteQuery.DeleteQueryProvider)2