Skip to content

Commit 9a74697

Browse files
Unifiy things.
1 parent 832e033 commit 9a74697

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

examples/sdn6-rest/pom.xml

+26-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.6.4</version>
8+
<version>2.7.0-M2</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>org.neo4j.tips.sdn</groupId>
@@ -27,6 +27,11 @@
2727
<groupId>org.springframework.boot</groupId>
2828
<artifactId>spring-boot-starter-data-rest</artifactId>
2929
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.data</groupId>
32+
<artifactId>spring-data-neo4j</artifactId>
33+
<version>6.3.0-SNAPSHOT</version>
34+
</dependency>
3035
<dependency>
3136
<groupId>eu.michael-simons.neo4j</groupId>
3237
<artifactId>neo4j-migrations-spring-boot-starter</artifactId>
@@ -69,5 +74,25 @@
6974
</plugin>
7075
</plugins>
7176
</build>
77+
<repositories>
78+
<repository>
79+
<id>spring-milestones</id>
80+
<name>Spring Milestones</name>
81+
<url>https://repo.spring.io/milestone</url>
82+
<snapshots>
83+
<enabled>false</enabled>
84+
</snapshots>
85+
</repository>
86+
</repositories>
87+
<pluginRepositories>
88+
<pluginRepository>
89+
<id>spring-milestones</id>
90+
<name>Spring Milestones</name>
91+
<url>https://repo.spring.io/milestone</url>
92+
<snapshots>
93+
<enabled>false</enabled>
94+
</snapshots>
95+
</pluginRepository>
96+
</pluginRepositories>
7297

7398
</project>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package org.neo4j.tips.sdn.sdn6_rest;
22

3-
import org.neo4j.tips.sdn.sdn6_rest.movies.Actor;
43
import org.neo4j.tips.sdn.sdn6_rest.movies.Movie;
5-
import org.neo4j.tips.sdn.sdn6_rest.movies.Person;
64
import org.springframework.context.annotation.Bean;
75
import org.springframework.context.annotation.Configuration;
86
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
97
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
10-
import org.springframework.hateoas.EntityModel;
11-
import org.springframework.hateoas.server.EntityLinks;
12-
import org.springframework.hateoas.server.RepresentationModelProcessor;
138
import org.springframework.web.servlet.config.annotation.CorsRegistry;
149

1510
@Configuration(proxyBeanMethods = false)
@@ -25,17 +20,4 @@ public void configureRepositoryRestConfiguration(RepositoryRestConfiguration con
2520

2621
};
2722
}
28-
29-
@Bean
30-
RepresentationModelProcessor<EntityModel<Actor>> actorResourceProcessor(final EntityLinks entityLinks) {
31-
// Don't use a lambda here, otherwise the type will evaporate (some Spring thing I really don't wanna debug right now)
32-
return new RepresentationModelProcessor<EntityModel<Actor>>() {
33-
@Override public EntityModel<Actor> process(EntityModel<Actor> model) {
34-
if (model.getContent().getPerson() != null) {
35-
model.add(entityLinks.linkToItemResource(Person.class, model.getContent().getPerson().getId()));
36-
}
37-
return model;
38-
}
39-
};
40-
}
4123
}

examples/sdn6-rest/src/main/java/org/neo4j/tips/sdn/sdn6_rest/movies/Actor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public final class Actor {
1919
private Long id;
2020

2121
@TargetNode
22-
@JsonIgnore
22+
@JsonUnwrapped
23+
@JsonIgnoreProperties({ "id" })
2324
private final Person person;
2425

2526
private final List<String> roles;
@@ -37,5 +38,3 @@ public List<String> getRoles() {
3738
return List.copyOf(roles);
3839
}
3940
}
40-
41-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.neo4j.tips.sdn.sdn6_rest.movies;
2+
3+
import org.springframework.data.rest.core.config.Projection;
4+
5+
@Projection(name = "inlineName", types = { Person.class })
6+
public interface InlineName {
7+
8+
String getName();
9+
}

examples/sdn6-rest/src/main/java/org/neo4j/tips/sdn/sdn6_rest/movies/PeopleRepository.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
import org.springframework.data.neo4j.repository.Neo4jRepository;
77
import org.springframework.data.neo4j.repository.query.Query;
88
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
9-
import org.springframework.data.rest.core.annotation.RestResource;
109

1110
/**
1211
* @author Michael J. Simons
1312
*/
14-
@RepositoryRestResource(path = "people")
13+
@RepositoryRestResource(path = "people", excerptProjection = InlineName.class)
1514
public interface PeopleRepository extends Neo4jRepository<Person, UUID> {
1615

1716
@Query("""

examples/sdn6-rest/src/main/java/org/neo4j/tips/sdn/sdn6_rest/movies/Person.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.UUID;
44

55
import org.springframework.data.annotation.PersistenceConstructor;
6+
import org.springframework.data.annotation.PersistenceCreator;
67
import org.springframework.data.neo4j.core.schema.GeneratedValue;
78
import org.springframework.data.neo4j.core.schema.Id;
89
import org.springframework.data.neo4j.core.schema.Node;
@@ -19,7 +20,7 @@ public final class Person {
1920

2021
private Integer born;
2122

22-
@PersistenceConstructor
23+
@PersistenceCreator
2324
private Person(UUID id, String name, Integer born) {
2425
this.id = id;
2526
this.born = born;

0 commit comments

Comments
 (0)