List of usage examples for com.amazonaws.services.dynamodbv2.model ComparisonOperator CONTAINS
ComparisonOperator CONTAINS
To view the source code for com.amazonaws.services.dynamodbv2.model ComparisonOperator CONTAINS.
Click Source Link
From source file:com.makariev.dynamodb.preferences.UserPreferenceLowLevelAPIService.java
License:Open Source License
@Override public List<UserPreference> scanByFirstName(String searchForName) { final DynamoDBScanExpression scanExpression = new DynamoDBScanExpression(); scanExpression.addFilterCondition("firstName", new Condition().withComparisonOperator(ComparisonOperator.CONTAINS) .withAttributeValueList(new AttributeValue().withS(searchForName))); final Map<String, Condition> scanFilter = scanExpression.getScanFilter(); final ScanResult scanResult = dynamoDb.scan(UserPreference.TABLE_NAME, scanFilter); final List<Map<String, AttributeValue>> items = scanResult.getItems(); return toUserPreferenceList(items); }
From source file:com.makariev.dynamodb.preferences.UserPreferenceLowLevelAPIService.java
License:Open Source License
@Override public List<UserPreference> scanByLastName(String searchForName) { final DynamoDBScanExpression scanExpression = new DynamoDBScanExpression(); scanExpression.addFilterCondition("lastName", new Condition().withComparisonOperator(ComparisonOperator.CONTAINS) .withAttributeValueList(new AttributeValue().withS(searchForName))); final Map<String, Condition> scanFilter = scanExpression.getScanFilter(); final ScanResult scanResult = dynamoDb.scan(UserPreference.TABLE_NAME, scanFilter); final List<Map<String, AttributeValue>> items = scanResult.getItems(); return toUserPreferenceList(items); }
From source file:com.makariev.dynamodb.preferences.UserPreferenceObjectMapperService.java
License:Open Source License
@Override public List<UserPreference> scanByFirstName(String searchForName) { final DynamoDBScanExpression scanExpression = new DynamoDBScanExpression(); scanExpression.addFilterCondition("firstName", new Condition().withComparisonOperator(ComparisonOperator.CONTAINS) .withAttributeValueList(new AttributeValue().withS(searchForName))); final PaginatedScanList<UserPreference> scanList = mapper.scan(UserPreference.class, scanExpression); return scanList; }
From source file:com.makariev.dynamodb.preferences.UserPreferenceObjectMapperService.java
License:Open Source License
@Override public List<UserPreference> scanByLastName(String searchForName) { final DynamoDBScanExpression scanExpression = new DynamoDBScanExpression(); scanExpression.addFilterCondition("lastName", new Condition().withComparisonOperator(ComparisonOperator.CONTAINS) .withAttributeValueList(new AttributeValue().withS(searchForName))); final PaginatedScanList<UserPreference> scanList = mapper.scan(UserPreference.class, scanExpression); return scanList; }
From source file:org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCreator.java
License:Apache License
protected DynamoDBQueryCriteria<T, ID> addCriteria(DynamoDBQueryCriteria<T, ID> criteria, Part part, Iterator<Object> iterator) { if (part.shouldIgnoreCase().equals(IgnoreCaseType.ALWAYS)) throw new UnsupportedOperationException("Case insensitivity not supported"); Class<?> leafNodePropertyType = part.getProperty().getLeafProperty().getType(); PropertyPath leafNodePropertyPath = part.getProperty().getLeafProperty(); String leafNodePropertyName = leafNodePropertyPath.toDotPath(); if (leafNodePropertyName.indexOf(".") != -1) { int index = leafNodePropertyName.lastIndexOf("."); leafNodePropertyName = leafNodePropertyName.substring(index); }//from w w w . j av a 2 s.c o m switch (part.getType()) { case IN: Object in = iterator.next(); Assert.notNull(in, "Creating conditions on null parameters not supported: please specify a value for '" + leafNodePropertyName + "'"); boolean isIterable = ClassUtils.isAssignable(Iterable.class, in.getClass()); boolean isArray = ObjectUtils.isArray(in); Assert.isTrue(isIterable || isArray, "In criteria can only operate with Iterable or Array parameters"); Iterable<?> iterable = isIterable ? ((Iterable<?>) in) : Arrays.asList(ObjectUtils.toObjectArray(in)); return criteria.withPropertyIn(leafNodePropertyName, iterable, leafNodePropertyType); case CONTAINING: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.CONTAINS, iterator.next(), leafNodePropertyType); case STARTING_WITH: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.BEGINS_WITH, iterator.next(), leafNodePropertyType); case BETWEEN: Object first = iterator.next(); Object second = iterator.next(); return criteria.withPropertyBetween(leafNodePropertyName, first, second, leafNodePropertyType); case AFTER: case GREATER_THAN: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.GT, iterator.next(), leafNodePropertyType); case BEFORE: case LESS_THAN: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.LT, iterator.next(), leafNodePropertyType); case GREATER_THAN_EQUAL: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.GE, iterator.next(), leafNodePropertyType); case LESS_THAN_EQUAL: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.LE, iterator.next(), leafNodePropertyType); case IS_NULL: return criteria.withNoValuedCriteria(leafNodePropertyName, ComparisonOperator.NULL); case IS_NOT_NULL: return criteria.withNoValuedCriteria(leafNodePropertyName, ComparisonOperator.NOT_NULL); case TRUE: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.EQ, Boolean.TRUE, leafNodePropertyType); case FALSE: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.EQ, Boolean.FALSE, leafNodePropertyType); case SIMPLE_PROPERTY: return criteria.withPropertyEquals(leafNodePropertyName, iterator.next(), leafNodePropertyType); case NEGATING_SIMPLE_PROPERTY: return criteria.withSingleValueCriteria(leafNodePropertyName, ComparisonOperator.NE, iterator.next(), leafNodePropertyType); default: throw new IllegalArgumentException("Unsupported keyword " + part.getType()); } }
From source file:org.socialsignin.spring.data.dynamodb.repository.query.DynamoDBEntityWithHashAndRangeKeyCriteria.java
License:Apache License
private void checkComparisonOperatorPermittedForCompositeHashAndRangeKey( ComparisonOperator comparisonOperator) { if (!ComparisonOperator.EQ.equals(comparisonOperator) && !ComparisonOperator.CONTAINS.equals(comparisonOperator) && !ComparisonOperator.BEGINS_WITH.equals(comparisonOperator)) { throw new UnsupportedOperationException( "Only EQ,CONTAINS,BEGINS_WITH supported for composite id comparison"); }//from www .ja v a 2 s . c om }
From source file:org.socialsignin.spring.data.dynamodb.repository.query.DynamoDBQueryCreator.java
License:Apache License
protected DynamoDBQueryCriteria<T, ID> addCriteria(DynamoDBQueryCriteria<T, ID> criteria, Part part, Iterator<Object> iterator) { if (part.shouldIgnoreCase().equals(IgnoreCaseType.ALWAYS)) throw new UnsupportedOperationException("Case insensitivity not supported"); Class<?> propertyType = part.getProperty().getType(); switch (part.getType()) { case IN:// w w w.ja va 2 s .c o m Object in = iterator.next(); Assert.notNull(in, "Creating conditions on null parameters not supported: please specify a value for '" + part.getProperty().getSegment() + "'"); boolean isIterable = ClassUtils.isAssignable(in.getClass(), Iterable.class); boolean isArray = ObjectUtils.isArray(in); Assert.isTrue(isIterable || isArray, "In criteria can only operate with Iterable or Array parameters"); Iterable<?> iterable = isIterable ? ((Iterable<?>) in) : Arrays.asList(ObjectUtils.toObjectArray(in)); return criteria.withPropertyIn(part.getProperty().getSegment(), iterable, propertyType); case CONTAINING: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.CONTAINS, iterator.next(), propertyType); case STARTING_WITH: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.BEGINS_WITH, iterator.next(), propertyType); case BETWEEN: Object first = iterator.next(); Object second = iterator.next(); return criteria.withPropertyBetween(part.getProperty().getSegment(), first, second, propertyType); case AFTER: case GREATER_THAN: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.GT, iterator.next(), propertyType); case BEFORE: case LESS_THAN: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.LT, iterator.next(), propertyType); case GREATER_THAN_EQUAL: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.GE, iterator.next(), propertyType); case LESS_THAN_EQUAL: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.LE, iterator.next(), propertyType); case IS_NULL: return criteria.withNoValuedCriteria(part.getProperty().getSegment(), ComparisonOperator.NULL); case IS_NOT_NULL: return criteria.withNoValuedCriteria(part.getProperty().getSegment(), ComparisonOperator.NOT_NULL); case TRUE: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.EQ, Boolean.TRUE, propertyType); case FALSE: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.EQ, Boolean.FALSE, propertyType); case SIMPLE_PROPERTY: return criteria.withPropertyEquals(part.getProperty().getSegment(), iterator.next(), propertyType); case NEGATING_SIMPLE_PROPERTY: return criteria.withSingleValueCriteria(part.getProperty().getSegment(), ComparisonOperator.NE, iterator.next(), propertyType); default: throw new IllegalArgumentException("Unsupported keyword " + part.getType()); } }