Skip to content

Commit

Permalink
refactor: IDE auto code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden committed May 14, 2024
1 parent 0ee4f4e commit e271f15
Show file tree
Hide file tree
Showing 434 changed files with 11,387 additions and 10,916 deletions.
186 changes: 126 additions & 60 deletions README.md

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions demos/roms-documents/pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath /> <!-- lookup parent from repository -->
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.redis.om</groupId>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.1-SNAPSHOT</version>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -65,11 +65,11 @@
<version>${testcontainers.redis.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>-->
<!-- <version>2.0.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>-->
<!-- <version>2.0.0</version>-->
<!-- </dependency>-->
</dependencies>

<repositories>
Expand Down Expand Up @@ -147,7 +147,7 @@
<path>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.1-SNAPSHOT</version>
<version>0.9.1</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ public class RomsDocumentsApplication {
@Autowired
PersonRepository personRepo;

public static void main(String[] args) {
SpringApplication.run(RomsDocumentsApplication.class, args);
}

@Bean
CommandLineRunner loadTestData() {
return args -> {
companyRepo.deleteAll();
Company redis = Company.of("Redis", "https://redis.com", new Point(-122.066540, 37.377690), 526, 2011, Set.of(CompanyMeta.of("Redis", 100, Set.of("RedisTag"))));
Company redis = Company.of("Redis", "https://redis.com", new Point(-122.066540, 37.377690), 526, 2011,
Set.of(CompanyMeta.of("Redis", 100, Set.of("RedisTag"))));
redis.setTags(Set.of("fast", "scalable", "reliable"));

Company microsoft = Company.of("Microsoft", "https://microsoft.com", new Point(-122.124500, 47.640160), 182268, 1975, Set.of(CompanyMeta.of("MS", 50, Set.of("MsTag"))));
Company microsoft = Company.of("Microsoft", "https://microsoft.com", new Point(-122.124500, 47.640160), 182268,
1975, Set.of(CompanyMeta.of("MS", 50, Set.of("MsTag"))));
microsoft.setTags(Set.of("innovative", "reliable"));

companyRepo.save(redis);
Expand All @@ -46,8 +52,4 @@ CommandLineRunner loadTestData() {
};
}

public static void main(String[] args) {
SpringApplication.run(RomsDocumentsApplication.class, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@
public class CompanyController {
@Autowired
CompanyRepository repository;

@GetMapping("employees/count/{count}")
Iterable<Company> byNumberOfEmployees(@PathVariable("count") int count) {
return repository.findByNumberOfEmployees(count);
}

@GetMapping("employees/range/{low}/{high}")
Iterable<Company> byNumberOfEmployeesRange(@PathVariable("low") int low, @PathVariable("high") int high) {
return repository.findByNumberOfEmployeesBetween(low, high);
}

@GetMapping("all")
Page<Company> all(Pageable pageable) {
return repository.findAll(pageable);
}

@GetMapping("all-ids")
Page<String> allIds(Pageable pageable) {
return repository.getIds(pageable);
}

@GetMapping("near")
Iterable<Company> byLocationNear(//
@RequestParam("lat") double lat, //
@RequestParam("lon") double lon, //
@RequestParam("d") double distance) {
@RequestParam("lat") double lat, //
@RequestParam("lon") double lon, //
@RequestParam("d") double distance) {
return repository.findByLocationNear(new Point(lon, lat), new Distance(distance, Metrics.MILES));
}

@GetMapping("name/starts/{prefix}")
Iterable<Company> byNameStartingWith(@PathVariable("prefix") String prefix) {
return repository.findByNameStartingWith(prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
@RequiredArgsConstructor
public class EventController {

private final EventService eventService;
private final EventService eventService;

@GetMapping("between")
List<Event> byNumberOfEmployees(@RequestParam("start")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime start,
@RequestParam("end")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime end) {
return eventService.searchByBeginDateBetween(start, end);
}
@GetMapping("between")
List<Event> byNumberOfEmployees(
@RequestParam("start") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime start,
@RequestParam("end") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime end) {
return eventService.searchByBeginDateBetween(start, end);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
public class PersonController {
@Autowired
PersonRepository repository;

@GetMapping("all")
Page<Person> all(Pageable pageable) {
return repository.findAll(pageable);
}

@GetMapping("all-ids")
Page<String> allIds(Pageable pageable) {
return repository.getIds(pageable);
}

@GetMapping("name/{last}/{first}")
List<Person> byLastAndFirst(//
@PathVariable("last") String last, @PathVariable("first") String first) {
@PathVariable("last") String last, @PathVariable("first") String first) {
return repository.findByLastNameAndFirstName(last, first);
}

@GetMapping("{id}")
Optional<Person> byId(@PathVariable("id") String id) {
return repository.findById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public class Company {
private Set<CompanyMeta> metaList;

private boolean publiclyListed;

// audit fields

@CreatedDate
private Date createdDate;

@LastModifiedDate
private Date lastModifiedDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
@AllArgsConstructor
@Document
public class Event {
@Id
private String id;
@Id
private String id;

@NonNull
@Searchable
private String name;
@NonNull
@Searchable
private String name;

@Indexed
private LocalDateTime beginDate;
@Indexed
private LocalDateTime beginDate;

@Indexed
private LocalDateTime endDate;
@Indexed
private LocalDateTime endDate;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
public class Person {
@Id
private String id;

@NonNull
@TextIndexed
private String firstName;

@NonNull
@TextIndexed
private String lastName;

@NonNull
@TagIndexed
private String email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
public interface CompanyRepository extends RedisDocumentRepository<Company, String> {
// find one by property
Optional<Company> findOneByName(String name);

// geospatial query
Iterable<Company> findByLocationNear(Point point, Distance distance);
Iterable<Company> findByLocationNear(Point point, Distance distance);

// find by tag field, using JRediSearch "native" annotation
@Query("@tags:{$tags}")
Iterable<Company> findByTags(@Param("tags") Set<String> tags);

// find by numeric property
Iterable<Company> findByNumberOfEmployees(int noe);

// find by numeric property range
Iterable<Company> findByNumberOfEmployeesBetween(int noeGT, int noeLT);

// starting with/ending with
Iterable<Company> findByNameStartingWith(String prefix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import java.util.List;

public interface EventService {
List<Event> searchByBeginDateBetween(LocalDateTime start, LocalDateTime end);
List<Event> searchByBeginDateBetween(LocalDateTime start, LocalDateTime end);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
@RequiredArgsConstructor
public class EventServiceImpl implements EventService {

private final EntityStream entityStream;
private final EntityStream entityStream;

@Override
public List<Event> searchByBeginDateBetween(LocalDateTime start, LocalDateTime end) {
@Override
public List<Event> searchByBeginDateBetween(LocalDateTime start, LocalDateTime end) {

return entityStream.of(Event.class)
.filter(Event$.BEGIN_DATE.between(start, end))
.collect(Collectors.toList());
}
return entityStream.of(Event.class).filter(Event$.BEGIN_DATE.between(start, end)).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
@Testcontainers
@DirtiesContext
@SpringBootTest(
classes = AbstractDocumentTest.Config.class,
properties = {"spring.main.allow-bean-definition-overriding=true"}
classes = AbstractDocumentTest.Config.class, properties = { "spring.main.allow-bean-definition-overriding=true" }
)
public abstract class AbstractDocumentTest extends AbstractTest {
@SpringBootApplication
@Configuration
@EnableRedisDocumentRepositories
static class Config extends TestConfig {
}
@SpringBootApplication
@Configuration
@EnableRedisDocumentRepositories
static class Config extends TestConfig {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@
@Testcontainers(disabledWithoutDocker = true)
@DirtiesContext
public abstract class AbstractTest {
@Container
static final RedisStackContainer REDIS;
@Container
static final RedisStackContainer REDIS;

static {
REDIS = new RedisStackContainer(DEFAULT_IMAGE_NAME.withTag("edge")).withReuse(true);
REDIS.start();
}
static {
REDIS = new RedisStackContainer(DEFAULT_IMAGE_NAME.withTag("edge")).withReuse(true);
REDIS.start();
}

@Autowired
protected StringRedisTemplate template;
@Autowired
protected StringRedisTemplate template;

@Autowired
protected RedisModulesOperations<String> modulesOperations;
@Autowired
protected RedisModulesOperations<String> modulesOperations;

@Autowired
@Qualifier("redisCustomKeyValueTemplate")
protected CustomRedisKeyValueTemplate kvTemplate;
@Autowired
@Qualifier("redisCustomKeyValueTemplate")
protected CustomRedisKeyValueTemplate kvTemplate;

@Autowired
protected RediSearchIndexer indexer;
@Autowired
protected RediSearchIndexer indexer;

@DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.host", REDIS::getHost);
registry.add("spring.redis.port", REDIS::getFirstMappedPort);
}
@DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.host", REDIS::getHost);
registry.add("spring.redis.port", REDIS::getFirstMappedPort);
}

protected void flushSearchIndexFor(Class<?> entityClass) {
indexer.dropIndexAndDocumentsFor(entityClass);
indexer.createIndexFor(entityClass);
}
protected void flushSearchIndexFor(Class<?> entityClass) {
indexer.dropIndexAndDocumentsFor(entityClass);
indexer.createIndexFor(entityClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//@SpringBootTest
class RomsDocumentsApplicationTests {

@Test
void contextLoads() {
}
@Test
void contextLoads() {
}

}
Loading

0 comments on commit e271f15

Please sign in to comment.