Refactor spring-data-neo4j
This commit is contained in:
parent
204ad9586b
commit
99963ee271
|
@ -12,6 +12,7 @@ import java.util.Map;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface MovieRepository extends GraphRepository<Movie> {
|
public interface MovieRepository extends GraphRepository<Movie> {
|
||||||
|
|
||||||
Movie findByTitle(@Param("title") String title);
|
Movie findByTitle(@Param("title") String title);
|
||||||
|
|
||||||
@Query("MATCH (m:Movie) WHERE m.title =~ ('(?i).*'+{title}+'.*') RETURN m")
|
@Query("MATCH (m:Movie) WHERE m.title =~ ('(?i).*'+{title}+'.*') RETURN m")
|
||||||
|
|
|
@ -6,5 +6,4 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface PersonRepository extends GraphRepository<Person> {
|
public interface PersonRepository extends GraphRepository<Person> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ import java.util.*;
|
||||||
public class MovieService {
|
public class MovieService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
MovieRepository movieRepository;
|
private MovieRepository movieRepository;
|
||||||
|
|
||||||
private Map<String, Object> toD3Format(Iterator<Map<String, Object>> result) {
|
private Map<String, Object> toD3Format(Iterator<Map<String, Object>> result) {
|
||||||
List<Map<String, Object>> nodes = new ArrayList<Map<String, Object>>();
|
List<Map<String, Object>> nodes = new ArrayList<>();
|
||||||
List<Map<String, Object>> rels = new ArrayList<Map<String, Object>>();
|
List<Map<String, Object>> rels = new ArrayList<>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (result.hasNext()) {
|
while (result.hasNext()) {
|
||||||
Map<String, Object> row = result.next();
|
Map<String, Object> row = result.next();
|
||||||
|
@ -37,7 +37,7 @@ public class MovieService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> map(String key1, Object value1, String key2, Object value2) {
|
private Map<String, Object> map(String key1, Object value1, String key2, Object value2) {
|
||||||
Map<String, Object> result = new HashMap<String, Object>(2);
|
Map<String, Object> result = new HashMap<>(2);
|
||||||
result.put(key1, value1);
|
result.put(key1, value1);
|
||||||
result.put(key2, value2);
|
result.put(key2, value2);
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue