Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions demos/roms-documents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<maven.compiler.target>11</maven.compiler.target>
<maven.test.source>11</maven.test.source>
<maven.test.target>11</maven.test.target>
<testcontainers.redis.version>1.5.2</testcontainers.redis.version>
<testcontainers.redis.junit.version>1.4.6</testcontainers.redis.junit.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -51,6 +53,46 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency> -->
<dependency>
<groupId>com.redis.testcontainers</groupId>
<artifactId>testcontainers-redis</artifactId>
<version>${testcontainers.redis.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.redis.testcontainers</groupId>
<artifactId>testcontainers-redis-junit-jupiter</artifactId>
<version>${testcontainers.redis.junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.redis.om.documents;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
//@SpringBootTest
class RomsDocumentsApplicationTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.redis.om.hashes;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
//@SpringBootTest
class RomsHashesApplicationTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.redis.om.permits;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
//@SpringBootTest
class PermitsApplicationTests {

@Test
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring-parent</artifactId>
<version>0.2.0-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
<name>redis-om-spring-parent</name>
<packaging>pom</packaging>

Expand Down
40 changes: 28 additions & 12 deletions redis-om-spring/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.2.0-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>redis-om-spring</name>
Expand Down Expand Up @@ -61,6 +63,7 @@
<jredisearch.version>2.2.0</jredisearch.version>
<jredisbloom.version>2.2.0</jredisbloom.version>
<cdi>1.0</cdi>
<auto-service.version>1.0.1</auto-service.version>
<testcontainers.redis.version>1.5.2</testcontainers.redis.version>
<testcontainers.redis.junit.version>1.4.6</testcontainers.redis.junit.version>
</properties>
Expand Down Expand Up @@ -154,6 +157,18 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${auto-service.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>javapoet</artifactId>
<version>1.13.0</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -244,21 +259,21 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
</plugin>
</plugins>
</build>
<profiles>
Expand Down Expand Up @@ -294,7 +309,8 @@
</executions>
</plugin>

<!--Sign the components - this is required by maven central for releases -->
<!--Sign the components - this is required by maven central for
releases -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import com.redis.om.spring.ops.json.JSONOperations;
import com.redis.om.spring.ops.pds.BloomOperations;
import com.redis.om.spring.ops.search.SearchOperations;
import com.redis.om.spring.search.stream.EntityStream;
import com.redis.om.spring.search.stream.EntityStreamImpl;

import io.redisearch.FieldName;
import io.redisearch.Schema;
Expand All @@ -65,6 +67,7 @@
@EnableConfigurationProperties(RedisProperties.class)
@EnableAspectJAutoProxy
@ComponentScan("com.redis.om.spring.bloom")
@ComponentScan("com.redis.om.spring.metamodel")
public class RedisModulesConfiguration extends CachingConfigurerSupport {

private static final Log logger = LogFactory.getLog(RedisModulesConfiguration.class);
Expand Down Expand Up @@ -117,6 +120,11 @@ public CustomRedisKeyValueTemplate getKeyValueTemplate(RedisOperations<?, ?> red
RedisMappingContext mappingContext = new RedisMappingContext();
return new CustomRedisKeyValueTemplate(new RedisEnhancedKeyValueAdapter(redisOps), mappingContext);
}

@Bean(name = "streamingQueryBuilder")
EntityStream streamingQueryBuilder(RedisModulesOperations<?, ?> redisModulesOperations) {
return new EntityStreamImpl(redisModulesOperations);
}

@EventListener(ContextRefreshedEvent.class)
public void ensureIndexesAreCreated(ContextRefreshedEvent cre) {
Expand Down Expand Up @@ -170,8 +178,8 @@ private void createIndicesFor(Class<?> cls, ApplicationContext ac) {
String scoreField = null;
try {
Class<?> cl = Class.forName(beanDef.getBeanClassName());
indexName = cl.getSimpleName() + "Idx";
logger.info(String.format("Found @%s annotated class: %s", cls.getSimpleName(), cl.getSimpleName()));
indexName = cl.getName() + "Idx";
logger.info(String.format("Found @%s annotated class: %s", cls.getSimpleName(), cl.getName()));

List<Field> fields = new ArrayList<Field>();

Expand Down Expand Up @@ -227,7 +235,7 @@ private List<Field> findIndexFields(java.lang.reflect.Field field, String prefix
List<Field> fields = new ArrayList<Field>();

if (field.isAnnotationPresent(Indexed.class)) {
logger.debug(String.format("FOUND @Indexed annotation on field of type: %s", field.getType()));
logger.info(String.format("FOUND @Indexed annotation on field of type: %s", field.getType()));

Indexed indexed = (Indexed) field.getAnnotation(Indexed.class);

Expand Down Expand Up @@ -267,6 +275,7 @@ else if (field.getType() == Point.class) {

// Searchable - behaves like Text indexed
else if (field.isAnnotationPresent(Searchable.class)) {
logger.info(String.format("FOUND @Searchable annotation on field of type: %s", field.getType()));
Searchable searchable = field.getAnnotation(Searchable.class);
fields.add(indexAsTextFieldFor(field, isDocument, prefix, searchable));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.redis.om.spring.metamodel;

import java.lang.reflect.Field;

import com.redis.om.spring.search.stream.predicates.BetweenPredicate;
import com.redis.om.spring.search.stream.predicates.GreaterThanOrEqualPredicate;
import com.redis.om.spring.search.stream.predicates.GreaterThanPredicate;
import com.redis.om.spring.search.stream.predicates.LessThanOrEqualPredicate;
import com.redis.om.spring.search.stream.predicates.LessThanPredicate;

public class DateFieldOperationInterceptor<E, T> extends FieldOperationInterceptor<E, T> {

public DateFieldOperationInterceptor(Field field, boolean indexed) {
super(field, indexed);
}

public GreaterThanPredicate<? super E,T> after(T value) {
return new GreaterThanPredicate<E,T>(field,value);
}

public GreaterThanOrEqualPredicate<? super E,T> onOrAfter(T value) {
return new GreaterThanOrEqualPredicate<E,T>(field,value);
}

public LessThanPredicate<? super E,T> before(T value) {
return new LessThanPredicate<E,T>(field,value);
}

public LessThanOrEqualPredicate<? super E,T> onOrBefore(T value) {
return new LessThanOrEqualPredicate<E,T>(field,value);
}

public BetweenPredicate<? super E,T> between(T min, T max) {
return new BetweenPredicate<E,T>(field,min,max);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.redis.om.spring.metamodel;

import java.lang.reflect.Field;
import java.util.Comparator;
import java.util.function.Function;

import com.redis.om.spring.search.stream.predicates.EqualPredicate;
import com.redis.om.spring.search.stream.predicates.NotEqualPredicate;

public class FieldOperationInterceptor<E, T> implements Comparator<E>, Function<E,T> {

protected final Field field;
protected final boolean indexed;

public FieldOperationInterceptor(Field field, boolean indexed) {
this.field = field;
this.indexed = indexed;
}

public Field getField() {
return field;
}

public EqualPredicate<? super E,T> eq(T value) {
return new EqualPredicate<E,T>(field,value);
}

public NotEqualPredicate<? super E,T> notEq(T value) {
return new NotEqualPredicate<E,T>(field,value);
}

@Override
public int compare(E o1, E o2) {
// TODO Auto-generated method stub
return 0;
}

@Override
public T apply(E t) {
// TODO Auto-generated method stub
return null;
}

public boolean isIndexed() {
return indexed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.redis.om.spring.metamodel;

import java.lang.reflect.Field;

import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;

import com.redis.om.spring.search.stream.predicates.NearPredicate;

public class GeoFieldOperationInterceptor<E, T> extends FieldOperationInterceptor<E, T> {

public GeoFieldOperationInterceptor(Field field, boolean indexed) {
super(field, indexed);
}

public NearPredicate<? super E,T> near(Point point, Distance distance) {
return new NearPredicate<E,T>(field,point,distance);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.redis.om.spring.metamodel;

public class IllegalJavaBeanException extends RuntimeException {

private static final long serialVersionUID = 92362727623423324L;

public IllegalJavaBeanException(final Class<?> clazz, final String fieldName) {
super(String.format(
"The field '%s.%s' could not be matched to any getter. Please update your %s class to reflect standard JavaBean notation.",
clazz.getName(), fieldName, clazz.getName()));
}

}
Loading