org.springframework.data.repository.query.parser.PartTree.OrPart Java Examples

The following examples show how to use org.springframework.data.repository.query.parser.PartTree.OrPart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartTreeDatastoreQuery.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
private void validateAndSetFilterParts() {
	if (this.tree.isDistinct()) {
		throw new UnsupportedOperationException(
				"Cloud Datastore structured queries do not support the Distinct keyword.");
	}

	List<OrPart> parts = this.tree.get().collect(Collectors.toList());
	if (parts.size() > 0) {
		if (parts.size() > 1) {
			throw new DatastoreDataException(
					"Cloud Datastore only supports multiple filters combined with AND.");
		}
		this.filterParts = this.tree.getParts().get().collect(Collectors.toList());
	}
	else {
		this.filterParts = Collections.emptyList();
	}
}
 
Example #2
Source File: ReactivePartTreeNeo4jQuery.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
private ReactivePartTreeNeo4jQuery(
	ReactiveNeo4jOperations neo4jOperations,
	Neo4jMappingContext mappingContext,
	Neo4jQueryMethod queryMethod,
	PartTree tree
) {
	super(neo4jOperations, mappingContext, queryMethod, Neo4jQueryType.fromPartTree(tree));

	this.tree = tree;
	// Validate parts. Sort properties will be validated by Spring Data already.
	PartValidator validator = new PartValidator(queryMethod);
	this.tree.flatMap(OrPart::stream).forEach(validator::validatePart);
}
 
Example #3
Source File: PartTreeNeo4jQuery.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
private PartTreeNeo4jQuery(
	Neo4jOperations neo4jOperations,
	Neo4jMappingContext mappingContext,
	Neo4jQueryMethod queryMethod,
	PartTree tree
) {
	super(neo4jOperations, mappingContext, queryMethod, Neo4jQueryType.fromPartTree(tree));

	this.tree = tree;
	// Validate parts. Sort properties will be validated by Spring Data already.
	PartValidator validator = new PartValidator(queryMethod);
	this.tree.flatMap(OrPart::stream).forEach(validator::validatePart);
}
 
Example #4
Source File: PartTreeConverter.java    From spring-data-simpledb with MIT License 5 votes vote down vote up
/**
 * Convert a {@link PartTree} into a where query alike to the one present in the
 * {@link Query}'s where property.  
 */
public static String toIndexedQuery(final PartTree tree) {
	final StringBuilder result = new StringBuilder();
	
	final Iterator<OrPart> orIt = tree.iterator();
	while(orIt.hasNext()) {
		
		final OrPart orPart = orIt.next();
		
		final Iterator<Part> partIt = orPart.iterator();
		while(partIt.hasNext()) {
			final Part part = partIt.next();
			
			result.append(" " + part.getProperty().getSegment() + " ");
			result.append(convertOperator(part.getType()));
			
			if(partIt.hasNext()) {
				result.append(" AND ");
			}
		}
		
		if(orIt.hasNext()) {
			result.append(" OR ");
		}
	}
	
	return StringUtil.removeExtraSpaces(result.toString());
}