Search in sources :

Example 1 with IN

use of org.springframework.data.repository.query.parser.Part.Type.IN in project spring-cloud-gcp by spring-cloud.

the class PartTreeFirestoreQuery method validate.

private void validate() {
    List parts = this.tree.get().collect(Collectors.toList());
    if (parts.size() > 1 && parts.get(0) instanceof PartTree.OrPart) {
        throw new FirestoreDataException("Cloud Firestore doesn't support 'OR' (method name: " + this.getQueryMethod().getName() + ")");
    }
    List<String> unsupportedParts = this.tree.getParts().stream().filter(part -> !isSupportedPart(part.getType())).map(part -> part.getType().toString()).collect(Collectors.toList());
    if (!unsupportedParts.isEmpty()) {
        throw new FirestoreDataException("Unsupported predicate keywords: " + unsupportedParts + " in " + this.getQueryMethod().getName());
    }
}
Also used : GREATER_THAN(org.springframework.data.repository.query.parser.Part.Type.GREATER_THAN) Arrays(java.util.Arrays) Order(org.springframework.data.domain.Sort.Order) FieldReference(com.google.firestore.v1.StructuredQuery.FieldReference) QueryMethod(org.springframework.data.repository.query.QueryMethod) LESS_THAN_EQUAL(org.springframework.data.repository.query.parser.Part.Type.LESS_THAN_EQUAL) Part(org.springframework.data.repository.query.parser.Part) ArrayList(java.util.ArrayList) NOT_IN(org.springframework.data.repository.query.parser.Part.Type.NOT_IN) NEGATING_SIMPLE_PROPERTY(org.springframework.data.repository.query.parser.Part.Type.NEGATING_SIMPLE_PROPERTY) Map(java.util.Map) MapBuilder(org.springframework.cloud.gcp.core.util.MapBuilder) StreamSupport(java.util.stream.StreamSupport) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) Direction(org.springframework.data.domain.Sort.Direction) Int32Value(com.google.protobuf.Int32Value) LESS_THAN(org.springframework.data.repository.query.parser.Part.Type.LESS_THAN) ParametersParameterAccessor(org.springframework.data.repository.query.ParametersParameterAccessor) Iterator(java.util.Iterator) StructuredQuery(com.google.firestore.v1.StructuredQuery) FirestorePersistentEntity(org.springframework.cloud.gcp.data.firestore.mapping.FirestorePersistentEntity) PartTree(org.springframework.data.repository.query.parser.PartTree) FirestoreReactiveOperations(org.springframework.cloud.gcp.data.firestore.FirestoreReactiveOperations) ParameterAccessor(org.springframework.data.repository.query.ParameterAccessor) SIMPLE_PROPERTY(org.springframework.data.repository.query.parser.Part.Type.SIMPLE_PROPERTY) Collectors(java.util.stream.Collectors) CONTAINING(org.springframework.data.repository.query.parser.Part.Type.CONTAINING) List(java.util.List) IN(org.springframework.data.repository.query.parser.Part.Type.IN) ReturnedType(org.springframework.data.repository.query.ReturnedType) GREATER_THAN_EQUAL(org.springframework.data.repository.query.parser.Part.Type.GREATER_THAN_EQUAL) FirestoreClassMapper(org.springframework.cloud.gcp.data.firestore.mapping.FirestoreClassMapper) PropertyPath(org.springframework.data.mapping.PropertyPath) FirestoreDataException(org.springframework.cloud.gcp.data.firestore.FirestoreDataException) FirestoreMappingContext(org.springframework.cloud.gcp.data.firestore.mapping.FirestoreMappingContext) RepositoryQuery(org.springframework.data.repository.query.RepositoryQuery) FirestoreDataException(org.springframework.cloud.gcp.data.firestore.FirestoreDataException) ArrayList(java.util.ArrayList) List(java.util.List) PartTree(org.springframework.data.repository.query.parser.PartTree)

Aggregations

StructuredQuery (com.google.firestore.v1.StructuredQuery)1 FieldReference (com.google.firestore.v1.StructuredQuery.FieldReference)1 Int32Value (com.google.protobuf.Int32Value)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 MapBuilder (org.springframework.cloud.gcp.core.util.MapBuilder)1 FirestoreDataException (org.springframework.cloud.gcp.data.firestore.FirestoreDataException)1 FirestoreReactiveOperations (org.springframework.cloud.gcp.data.firestore.FirestoreReactiveOperations)1 FirestoreClassMapper (org.springframework.cloud.gcp.data.firestore.mapping.FirestoreClassMapper)1 FirestoreMappingContext (org.springframework.cloud.gcp.data.firestore.mapping.FirestoreMappingContext)1 FirestorePersistentEntity (org.springframework.cloud.gcp.data.firestore.mapping.FirestorePersistentEntity)1 Pageable (org.springframework.data.domain.Pageable)1 Sort (org.springframework.data.domain.Sort)1 Direction (org.springframework.data.domain.Sort.Direction)1 Order (org.springframework.data.domain.Sort.Order)1