Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Issue #114: Scanning by nested properties #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
119 changes: 119 additions & 0 deletions pom.xml
Expand Up @@ -46,6 +46,7 @@

<cdi.version>1.2</cdi.version>
<slf4j-test.version>1.2.0</slf4j-test.version>
<sqlite4java.version>1.0.392</sqlite4java.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down Expand Up @@ -97,6 +98,12 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<version>[1.11,2.0)</version>
</dependency>

<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
Expand Down Expand Up @@ -153,6 +160,11 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>DynamoDBLocal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -387,6 +399,7 @@
<table>src/test/resources/customerhistory_table.json</table>
<table>src/test/resources/installation_table.json</table>
<table>src/test/resources/auditable_user_table.json</table>
<table>src/test/resources/person_table.json</table>
</tables>
<port>${dynamodblocal.port}</port>
<dist>${project.build.directory}/dynamodb-dist</dist>
Expand All @@ -411,6 +424,43 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>test-compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.almworks.sqlite4java</groupId>
<artifactId>${sqlite4java.artifactId}</artifactId>
<version>${sqlite4java.version}</version>
<type>${sqlite4java.type}</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>sqlite4java.library.path</name>
<value>${project.build.directory}/lib</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down Expand Up @@ -444,6 +494,11 @@
<id>spring-libs-snapshot</id>
<url>http://repo.springsource.org/libs-snapshot</url>
</repository>
<repository>
<id>dynamodb-local-oregon</id>
<name>DynamoDB Local Release Repository</name>
<url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</url>
</repository>
</repositories>

<pluginRepositories>
Expand All @@ -457,6 +512,70 @@
</pluginRepositories>

<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<sqlite4java.artifactId>libsqlite4java-osx</sqlite4java.artifactId>
<sqlite4java.type>dylib</sqlite4java.type>
</properties>
</profile>
<profile>
<id>linux-x32</id>
<activation>
<os>
<family>unix</family>
<arch>i386</arch>
</os>
</activation>
<properties>
<sqlite4java.artifactId>libsqlite4java-linux-i386</sqlite4java.artifactId>
<sqlite4java.type>so</sqlite4java.type>
</properties>
</profile>
<profile>
<id>linux-x64</id>
<activation>
<os>
<family>unix</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<sqlite4java.artifactId>libsqlite4java-linux-amd64</sqlite4java.artifactId>
<sqlite4java.type>so</sqlite4java.type>
</properties>
</profile>
<profile>
<id>windows-x86</id>
<activation>
<os>
<family>windows</family>
<arch>x86</arch>
</os>
</activation>
<properties>
<sqlite4java.artifactId>libsqlite4java-win32-x86</sqlite4java.artifactId>
<sqlite4java.type>dll</sqlite4java.type>
</properties>
</profile>
<profile>
<id>windows-x64</id>
<activation>
<os>
<family>windows</family>
<arch>x64</arch>
</os>
</activation>
<properties>
<sqlite4java.artifactId>libsqlite4java-win32-x64</sqlite4java.artifactId>
<sqlite4java.type>dll</sqlite4java.type>
</properties>
</profile>
<profile>
<id>release</id>
<build>
Expand Down
2 changes: 1 addition & 1 deletion src/changes/changes.xml
Expand Up @@ -20,7 +20,7 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
<properties>
<title>spring-data-dynamodb Changes</title>
<author email="zeeman@zeeman.de" >derjust</author>
<author email="zeeman@zeeman.de">derjust</author>
</properties>
<body>
<release version="5.0.2" date="" description="Maintenance release">
Expand Down
Expand Up @@ -71,14 +71,21 @@ protected DynamoDBQueryCriteria<T, ID> addCriteria(DynamoDBQueryCriteria<T, ID>
throw new UnsupportedOperationException("Case insensitivity not supported");

Class<?> leafNodePropertyType = part.getProperty().getLeafProperty().getType();

PropertyPath leafNodePropertyPath = part.getProperty().getLeafProperty();
String leafNodePropertyName = leafNodePropertyPath.toDotPath();

part.getProperty().forEach(System.out::println);

//PropertyPath leafNodePropertyPath = part.getProperty().getLeafProperty();
//String leafNodePropertyName = leafNodePropertyPath.toDotPath();
String leafNodePropertyName = part.getProperty().toDotPath();
//TODO #114 - is this correct?
//TODO max deepth of 32 supported by AWS
/*
if (leafNodePropertyName.indexOf(".") != -1)
{

int index = leafNodePropertyName.lastIndexOf(".");
leafNodePropertyName = leafNodePropertyName.substring(index);
}
}*/

switch (part.getType()) {

Expand Down
Expand Up @@ -50,7 +50,7 @@ public class DynamoDBEntityMetadataSupport<T, ID> implements DynamoDBHashKeyExtr
private List<String> globalIndexRangeKeyPropertyNames;

private String dynamoDBTableName;
private Map<String, String[]> globalSecondaryIndexNames = new HashMap<String, String[]>();
private Map<String, String[]> globalSecondaryIndexNames = new HashMap<>();

@Override
public String getDynamoDBTableName() {
Expand All @@ -70,9 +70,9 @@ public DynamoDBEntityMetadataSupport(final Class<T> domainType) {
DynamoDBTable table = this.domainType.getAnnotation(DynamoDBTable.class);
Assert.notNull(table, "Domain type must by annotated with DynamoDBTable!");
this.dynamoDBTableName = table.tableName();
this.globalSecondaryIndexNames = new HashMap<String, String[]>();
this.globalIndexHashKeyPropertyNames = new ArrayList<String>();
this.globalIndexRangeKeyPropertyNames = new ArrayList<String>();
this.globalSecondaryIndexNames = new HashMap<>();
this.globalIndexHashKeyPropertyNames = new ArrayList<>();
this.globalIndexRangeKeyPropertyNames = new ArrayList<>();
ReflectionUtils.doWithMethods(domainType, new MethodCallback() {
@Override
public void doWith(Method method) {
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.socialsignin.spring.data.dynamodb.domain.sample.CustomerHistory;
import org.socialsignin.spring.data.dynamodb.domain.sample.CustomerHistoryRepository;
import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
import org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -29,7 +30,7 @@


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={CustomerHistoryIT.TestAppConfig.class, ConfigurationTI.class})
@ContextConfiguration(classes={CustomerHistoryIT.TestAppConfig.class, DynamoDBResource.class})
public class CustomerHistoryIT {

@Configuration
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.socialsignin.spring.data.dynamodb.domain.sample.User;
import org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -30,7 +31,7 @@
* Integration test that interacts with DynamoDB Local instance.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={ConfigurationTI.class})
@ContextConfiguration(classes={DynamoDBResource.class})
public class DynamoDBTemplateIT {

@Autowired
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.junit.runner.RunWith;
import org.socialsignin.spring.data.dynamodb.domain.sample.FeedUserRepository;
import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
import org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
Expand All @@ -28,7 +29,7 @@
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={FeedUserIT.TestAppConfig.class, ConfigurationTI.class})
@ContextConfiguration(classes={FeedUserIT.TestAppConfig.class, DynamoDBResource.class})
public class FeedUserIT {

@Configuration
Expand Down
Expand Up @@ -17,8 +17,8 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.socialsignin.spring.data.dynamodb.core.ConfigurationTI;
import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
import org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -38,7 +38,7 @@
* Shows the usage of Hash+Range key combinations with global secondary indexes.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTI.class, GlobalSecondaryIndexWithRangeKeyIT.TestAppConfig.class})
@ContextConfiguration(classes = {DynamoDBResource.class, GlobalSecondaryIndexWithRangeKeyIT.TestAppConfig.class})
public class GlobalSecondaryIndexWithRangeKeyIT {

@Configuration
Expand Down
Expand Up @@ -17,8 +17,8 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.socialsignin.spring.data.dynamodb.core.ConfigurationTI;
import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
import org.socialsignin.spring.data.dynamodb.utils.DynamoDBResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -39,7 +39,7 @@
* github.com/spring-projects/spring-data-examples/master/jpa/java8</a>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTI.class, Jdk8IT.TestAppConfig.class})
@ContextConfiguration(classes = {DynamoDBResource.class, Jdk8IT.TestAppConfig.class})
public class Jdk8IT {

@Configuration
Expand Down
@@ -0,0 +1,37 @@
/**
* Copyright © 2013 spring-data-dynamodb (https://github.com/derjust/spring-data-dynamodb)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.socialsignin.spring.data.dynamodb.repository.query.nested;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDocument;

@DynamoDBDocument
public class Address {
private String city;
private String country;

public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}