org.springframework.data.mapping.PersistentPropertyPath Java Examples

The following examples show how to use org.springframework.data.mapping.PersistentPropertyPath. 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: CypherQueryCreator.java    From sdn-rx with Apache License 2.0 4 votes vote down vote up
PropertyPathWrapper(int index, PersistentPropertyPath<?> propertyPath) {
	this.index = index;
	propertyPathList = (List<PersistentProperty<?>>) propertyPath.toList();
	this.leafProperty = (Neo4jPersistentProperty) propertyPath.getRequiredLeafProperty();
}
 
Example #2
Source File: CypherQueryCreator.java    From sdn-rx with Apache License 2.0 4 votes vote down vote up
private Condition createImpl(Part part, Iterator<Object> actualParameters) {

		PersistentPropertyPath<Neo4jPersistentProperty> path = mappingContext
			.getPersistentPropertyPath(part.getProperty());
		Neo4jPersistentProperty persistentProperty = path.getRequiredLeafProperty();

		boolean ignoreCase = ignoreCase(part);
		switch (part.getType()) {
			case AFTER:
			case GREATER_THAN:
				return toCypherProperty(persistentProperty, ignoreCase)
					.gt(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case BEFORE:
			case LESS_THAN:
				return toCypherProperty(persistentProperty, ignoreCase)
					.lt(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case BETWEEN:
				return betweenCondition(persistentProperty, actualParameters, ignoreCase);
			case CONTAINING:
				return toCypherProperty(persistentProperty, ignoreCase)
					.contains(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case ENDING_WITH:
				return toCypherProperty(persistentProperty, ignoreCase)
					.endsWith(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case EXISTS:
				return Predicates.exists(toCypherProperty(persistentProperty));
			case FALSE:
				return toCypherProperty(persistentProperty, ignoreCase).isFalse();
			case GREATER_THAN_EQUAL:
				return toCypherProperty(persistentProperty, ignoreCase)
					.gte(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case IN:
				return toCypherProperty(persistentProperty, ignoreCase)
					.in(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case IS_EMPTY:
				return toCypherProperty(persistentProperty, ignoreCase).isEmpty();
			case IS_NOT_EMPTY:
				return toCypherProperty(persistentProperty, ignoreCase).isEmpty().not();
			case IS_NOT_NULL:
				return toCypherProperty(persistentProperty, ignoreCase).isNotNull();
			case IS_NULL:
				return toCypherProperty(persistentProperty, ignoreCase).isNull();
			case LESS_THAN_EQUAL:
				return toCypherProperty(persistentProperty, ignoreCase)
					.lte(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case LIKE:
				return likeCondition(persistentProperty, nextRequiredParameter(actualParameters).nameOrIndex,
					ignoreCase);
			case NEAR:
				return createNearCondition(persistentProperty, actualParameters);
			case NEGATING_SIMPLE_PROPERTY:
				return toCypherProperty(persistentProperty, ignoreCase)
					.isNotEqualTo(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case NOT_CONTAINING:
				return toCypherProperty(persistentProperty, ignoreCase)
					.contains(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase)).not();
			case NOT_IN:
				return toCypherProperty(persistentProperty, ignoreCase)
					.in(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase))
					.not();
			case NOT_LIKE:
				return likeCondition(persistentProperty, nextRequiredParameter(actualParameters).nameOrIndex,
					ignoreCase).not();
			case SIMPLE_PROPERTY:
				return toCypherProperty(persistentProperty, ignoreCase)
					.isEqualTo(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case STARTING_WITH:
				return toCypherProperty(persistentProperty, ignoreCase)
					.startsWith(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case REGEX:
				return toCypherProperty(persistentProperty, ignoreCase)
					.matches(toCypherParameter(nextRequiredParameter(actualParameters), ignoreCase));
			case TRUE:
				return toCypherProperty(persistentProperty, ignoreCase).isTrue();
			case WITHIN:
				return createWithinCondition(persistentProperty, actualParameters);
			default:
				throw new IllegalArgumentException("Unsupported part type: " + part.getType());
		}
	}
 
Example #3
Source File: VaultQueryCreator.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
private Predicate<String> createPredicate(Part part, Iterator<Object> parameters) {

		PersistentPropertyPath<VaultPersistentProperty> propertyPath = this.mappingContext
				.getPersistentPropertyPath(part.getProperty());

		if (propertyPath.getLeafProperty() != null && !propertyPath.getLeafProperty().isIdProperty()) {
			throw new InvalidDataAccessApiUsageException(
					String.format("Cannot create criteria for non-@Id property %s", propertyPath.getLeafProperty()));
		}

		VariableAccessor accessor = getVariableAccessor(part);

		Predicate<String> predicate = from(part, accessor, parameters);

		return it -> predicate.test(accessor.toString(it));
	}