├── .gitignore ├── README.adoc ├── benchmark.sh ├── build.sh ├── helidon-se-reactive ├── .dockerignore ├── Dockerfile ├── Dockerfile.jlink ├── Dockerfile.native ├── README.md ├── app.yaml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── helidon │ │ │ └── se │ │ │ └── reactive │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MovieService.java │ │ │ ├── PeopleRepository.java │ │ │ ├── PeopleService.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ ├── package-info.java │ │ │ └── support │ │ │ └── Neo4jHealthCheck.java │ └── resources │ │ ├── application.yaml │ │ └── logging.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── helidon │ └── se │ └── reactive │ └── ApplicationTest.java ├── micronaut-imperative ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── micronaut-cli.yml ├── mvnw ├── mvnw.bat ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── micronaut │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ └── support │ │ │ └── DefaultLivenessIndicator.java │ └── resources │ │ ├── META-INF │ │ └── native-image │ │ │ └── native-image.properties │ │ ├── application.yml │ │ └── logback.xml │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── micronaut │ └── imperative │ └── MicronautReactiveTest.java ├── micronaut-reactive ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── micronaut-cli.yml ├── mvnw ├── mvnw.bat ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── micronaut │ │ │ └── reactive │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ └── support │ │ │ └── DefaultLivenessIndicator.java │ └── resources │ │ ├── META-INF │ │ └── native-image │ │ │ └── native-image.properties │ │ ├── application.yml │ │ └── logback.xml │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── micronaut │ └── reactive │ └── MicronautReactiveTest.java ├── quarkus-imperative ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── docker │ │ ├── Dockerfile.fast-jar │ │ ├── Dockerfile.jvm │ │ └── Dockerfile.native │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── quarkus │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MovieResource.java │ │ │ ├── PeopleRepository.java │ │ │ ├── PeopleResource.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── quarkus │ └── imperative │ └── movies │ ├── EmbeddedNeo4jTestResource.java │ └── PeopleRepositoryTest.java ├── quarkus-ogm ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── neo4j │ │ └── examples │ │ └── jvm │ │ └── quarkus │ │ └── ogm │ │ ├── Application.java │ │ └── movies │ │ ├── Actor.java │ │ ├── Movie.java │ │ ├── MovieRepository.java │ │ ├── MovieResource.java │ │ ├── PeopleRepository.java │ │ ├── PeopleResource.java │ │ └── Person.java │ └── resources │ └── application.properties ├── quarkus-reactive ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── docker │ │ ├── Dockerfile.fast-jar │ │ ├── Dockerfile.jvm │ │ └── Dockerfile.native │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── quarkus │ │ │ └── reactive │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MovieResource.java │ │ │ ├── PeopleRepository.java │ │ │ ├── PeopleResource.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── quarkus │ └── reactive │ └── movies │ ├── EmbeddedNeo4jTestResource.java │ └── PeopleRepositoryTest.java ├── runTck.sh ├── spring-boot23-with-sdn-ogm ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ └── ApplicationIT.java ├── spring-boot24-with-sdn-ogm ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ └── support │ │ │ └── Neo4jOGMConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ ├── ApplicationIT.java │ └── movies │ └── PeopleRepositoryTest.java ├── spring-boot26-with-sdn-ogm ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ └── support │ │ │ └── Neo4jOGMConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ ├── ApplicationIT.java │ └── movies │ └── PeopleRepositoryTest.java ├── spring-boot27-with-sdn-ogm ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ ├── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ │ │ └── support │ │ │ └── Neo4jOGMConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ ├── ApplicationIT.java │ └── movies │ ├── MovieRepositoryTest.java │ └── PeopleRepositoryTest.java ├── spring-data-imperative-module-path ├── .gitignore ├── .mvn │ ├── jvm.config │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Dockerfile ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── java │ ├── module-info.java │ └── org │ │ └── neo4j │ │ └── examples │ │ └── jvm │ │ └── spring │ │ └── data │ │ └── imperative │ │ ├── Application.java │ │ └── movies │ │ ├── Actor.java │ │ ├── Movie.java │ │ ├── MovieRepository.java │ │ ├── MoviesController.java │ │ ├── PeopleController.java │ │ ├── PeopleRepository.java │ │ ├── Person.java │ │ └── PersonDetails.java │ └── resources │ └── application.properties ├── spring-data-imperative-native ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ └── ApplicationIT.java ├── spring-data-imperative ├── .gitignore ├── .mvn │ ├── jvm.config │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ ├── Neo4jConfig.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── ExtMovieRepository.java │ │ │ ├── ExtMovieRepositoryImpl.java │ │ │ ├── Movie.java │ │ │ ├── MovieDescription.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── imperative │ ├── ApplicationIT.java │ └── movies │ └── RepositoryTests.java ├── spring-data-reactive ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── data │ │ │ └── reactive │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── data │ └── reactive │ ├── ApplicationIT.java │ └── movies │ └── PeopleRepositoryTest.java ├── spring-plain-imperative ├── .gitignore ├── .mvn │ ├── jvm.config │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── plain │ │ │ └── imperative │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── plain │ └── imperative │ ├── ApplicationIT.java │ └── movies │ └── PeopleRepositoryTest.java ├── spring-plain-reactive ├── .gitignore ├── .mvn │ ├── jvm.config │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── spring │ │ │ └── plain │ │ │ └── reactive │ │ │ ├── Application.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── MovieRepository.java │ │ │ ├── MoviesController.java │ │ │ ├── PeopleController.java │ │ │ ├── PeopleRepository.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── org │ └── neo4j │ └── examples │ └── jvm │ └── spring │ └── plain │ └── reactive │ ├── ApplicationIT.java │ └── movies │ └── PeopleRepositoryTest.java ├── tck ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neo4j │ │ │ └── examples │ │ │ └── jvm │ │ │ └── tck │ │ │ ├── Application.java │ │ │ ├── cli │ │ │ ├── Cli.java │ │ │ ├── LoadMovies.java │ │ │ └── VerifyConnection.java │ │ │ └── movies │ │ │ ├── Actor.java │ │ │ ├── Movie.java │ │ │ ├── Person.java │ │ │ └── PersonDetails.java │ └── resources │ │ ├── application.properties │ │ └── neo4j │ │ ├── example-data │ │ ├── afterMigrate__create_example_data.cypher │ │ └── beforeMigrate__clean_database.cypher │ │ └── migrations │ │ ├── V0001__Remove_old_indexes.cypher │ │ ├── V0002__Create_movie_title_index.cypher │ │ └── V0003__Create_person_name_index.cypher │ └── test │ ├── java │ └── org │ │ └── neo4j │ │ └── examples │ │ └── jvm │ │ └── tck │ │ └── TckTest.java │ └── resources │ └── logback-test.xml └── vertx-spring-data-reactive ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src └── main ├── java └── org │ └── neo4j │ └── examples │ └── jvm │ └── vertx │ └── sdn │ ├── APIVerticle.java │ ├── Application.java │ ├── VertxRunner.java │ └── movies │ ├── Actor.java │ ├── Movie.java │ ├── MovieRepository.java │ ├── PeopleRepository.java │ ├── Person.java │ └── PersonDetails.java └── resources └── application.properties /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | .DS_Store 4 | var/ 5 | /application.properties 6 | /activemq-data/ 7 | /nbproject/ 8 | Thumbs.db 9 | \.*.swp 10 | 11 | ### IntelliJ IDEA ### 12 | .idea 13 | *.iws 14 | *.iml 15 | *.ipr 16 | -------------------------------------------------------------------------------- /helidon-se-reactive/.dockerignore: -------------------------------------------------------------------------------- 1 | target/* -------------------------------------------------------------------------------- /helidon-se-reactive/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | # 1st stage, build the app 3 | FROM maven:3.6-jdk-11 as build 4 | 5 | WORKDIR /helidon 6 | 7 | # Create a first layer to cache the "Maven World" in the local repository. 8 | # Incremental docker builds will always resume after that, unless you update 9 | # the pom 10 | ADD pom.xml . 11 | RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip 12 | 13 | # Do the Maven build! 14 | # Incremental docker builds will resume here when you change sources 15 | ADD src src 16 | RUN mvn package -DskipTests 17 | 18 | RUN echo "done!" 19 | 20 | # 2nd stage, build the runtime image 21 | FROM openjdk:11-jre-slim 22 | WORKDIR /helidon 23 | 24 | # Copy the binary built in the 1st stage 25 | COPY --from=build /helidon/target/helidon-se-reactive.jar ./ 26 | COPY --from=build /helidon/target/libs ./libs 27 | 28 | CMD ["java", "-jar", "helidon-se-reactive.jar"] 29 | 30 | EXPOSE 8080 31 | -------------------------------------------------------------------------------- /helidon-se-reactive/Dockerfile.jlink: -------------------------------------------------------------------------------- 1 | 2 | # 1st stage, build the app 3 | FROM maven:3.6.3-jdk-11-slim as build 4 | 5 | WORKDIR /helidon 6 | 7 | # Create a first layer to cache the "Maven World" in the local repository. 8 | # Incremental docker builds will always resume after that, unless you update 9 | # the pom 10 | ADD pom.xml . 11 | RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip 12 | 13 | # Do the Maven build to create the custom Java Runtime Image 14 | # Incremental docker builds will resume here when you change sources 15 | ADD src src 16 | RUN mvn -Ddocker.build=true package -Pjlink-image -DskipTests 17 | RUN echo "done!" 18 | 19 | # 2nd stage, build the final image with the JRI built in the 1st stage 20 | 21 | FROM debian:stretch-slim 22 | WORKDIR /helidon 23 | COPY --from=build /helidon/target/helidon-se-reactive ./ 24 | ENTRYPOINT ["/bin/bash", "/helidon/bin/start"] 25 | EXPOSE 8080 26 | -------------------------------------------------------------------------------- /helidon-se-reactive/Dockerfile.native: -------------------------------------------------------------------------------- 1 | 2 | # 1st stage, build the app 3 | FROM helidon/jdk11-graalvm-maven:21.0.0 as build 4 | 5 | WORKDIR /helidon 6 | 7 | # Create a first layer to cache the "Maven World" in the local repository. 8 | # Incremental docker builds will always resume after that, unless you update 9 | # the pom 10 | ADD pom.xml . 11 | RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip 12 | 13 | # Do the Maven build! 14 | # Incremental docker builds will resume here when you change sources 15 | ADD src src 16 | RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests 17 | 18 | RUN echo "done!" 19 | 20 | # 2nd stage, build the runtime image 21 | FROM scratch 22 | WORKDIR /helidon 23 | 24 | # Copy the binary built in the 1st stage 25 | COPY --from=build /helidon/target/helidon-se-reactive . 26 | 27 | ENTRYPOINT ["./helidon-se-reactive"] 28 | 29 | EXPOSE 8080 30 | -------------------------------------------------------------------------------- /helidon-se-reactive/app.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | kind: Service 18 | apiVersion: v1 19 | metadata: 20 | name: helidon-se-reactive 21 | labels: 22 | app: helidon-se-reactive 23 | spec: 24 | type: NodePort 25 | selector: 26 | app: helidon-se-reactive 27 | ports: 28 | - port: 8080 29 | targetPort: 8080 30 | name: http 31 | --- 32 | kind: Deployment 33 | apiVersion: apps/v1 34 | metadata: 35 | name: helidon-se-reactive 36 | spec: 37 | replicas: 1 38 | selector: 39 | matchLabels: 40 | app: helidon-se-reactive 41 | template: 42 | metadata: 43 | labels: 44 | app: helidon-se-reactive 45 | version: v1 46 | spec: 47 | containers: 48 | - name: helidon-se-reactive 49 | image: helidon-se-reactive 50 | imagePullPolicy: IfNotPresent 51 | ports: 52 | - containerPort: 8080 53 | --- 54 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/java/org/neo4j/examples/jvm/helidon/se/reactive/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.helidon.se.reactive.movies; 20 | 21 | import io.helidon.common.Reflected; 22 | 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @Reflected 31 | public final class Actor { 32 | 33 | private final Long id; 34 | 35 | private final String name; 36 | 37 | private final List roles; 38 | 39 | Actor(Long id, String name, final List roles) { 40 | this.id = id; 41 | this.name = name; 42 | this.roles = new ArrayList<>(roles); 43 | } 44 | 45 | public Actor(String name, final List roles) { 46 | this(-1L, name, roles); 47 | } 48 | 49 | public Actor withId(Long id) { 50 | return this.id == id ? this : new Actor(id, this.name, this.roles); 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public List getRoles() { 58 | return Collections.unmodifiableList(roles); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/java/org/neo4j/examples/jvm/helidon/se/reactive/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.helidon.se.reactive.movies; 2 | 3 | import static org.reactivestreams.FlowAdapters.toFlowPublisher; 4 | 5 | import io.helidon.common.reactive.Single; 6 | 7 | import java.util.Map; 8 | import java.util.concurrent.atomic.AtomicReference; 9 | 10 | import org.neo4j.driver.Driver; 11 | import org.neo4j.driver.reactive.RxSession; 12 | import org.neo4j.driver.types.Node; 13 | 14 | /** 15 | * @author Michael J. Simons 16 | */ 17 | public final class PeopleRepository { 18 | 19 | private final Driver driver; 20 | 21 | public PeopleRepository(Driver driver) { 22 | this.driver = driver; 23 | } 24 | 25 | public Single save(Person person) { 26 | 27 | var query = "" 28 | + "MERGE (p:Person {name: $name})\n" 29 | + "SET p.born = $born\n" 30 | + "RETURN p\n"; 31 | var parameters = Map.of("name", person.getName(), "born", person.getBorn()); 32 | 33 | var sessionHolder = new AtomicReference(); 34 | return Single 35 | .defer(() -> { 36 | var session = driver.rxSession(); 37 | sessionHolder.set(session); 38 | return Single.just(session); 39 | }) 40 | .flatMapSingle(session -> Single.create( 41 | toFlowPublisher(session.writeTransaction(tx -> tx.run(query, parameters).records())))) 42 | .map(r -> asPerson(r.get("p").asNode())) 43 | .onTerminate(() -> Single.create(toFlowPublisher(sessionHolder.get().close())) 44 | .toOptionalSingle() 45 | .subscribe(empty -> { 46 | })); 47 | } 48 | 49 | static Person asPerson(Node personNode) { 50 | return new Person(personNode.id(), personNode.get("name").asString(), personNode.get("born").asInt()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/java/org/neo4j/examples/jvm/helidon/se/reactive/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.helidon.se.reactive.movies; 20 | 21 | import io.helidon.common.Reflected; 22 | 23 | import javax.json.bind.annotation.JsonbCreator; 24 | import javax.json.bind.annotation.JsonbProperty; 25 | 26 | /** 27 | * @author Michael J. Simons 28 | */ 29 | @Reflected 30 | public final class Person { 31 | 32 | private final Long id; 33 | 34 | private final String name; 35 | 36 | private Integer born; 37 | 38 | Person(Long id, String name, Integer born) { 39 | this.id = id; 40 | this.born = born; 41 | this.name = name; 42 | } 43 | 44 | @JsonbCreator 45 | public Person(@JsonbProperty("name") String name, @JsonbProperty("born") Integer born) { 46 | this(null, name, born); 47 | } 48 | 49 | public Long getId() { 50 | return id; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public Integer getBorn() { 58 | return born; 59 | } 60 | 61 | public void setBorn(Integer born) { 62 | this.born = born; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/java/org/neo4j/examples/jvm/helidon/se/reactive/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.helidon.se.reactive.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/java/org/neo4j/examples/jvm/helidon/se/reactive/package-info.java: -------------------------------------------------------------------------------- 1 | 2 | package org.neo4j.examples.jvm.helidon.se.reactive; 3 | -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | host: 0.0.0.0 4 | 5 | neo4j: 6 | uri: bolt://localhost:7687 7 | authentication: 8 | username: neo4j 9 | password: secret 10 | pool: 11 | metricsEnabled: true -------------------------------------------------------------------------------- /helidon-se-reactive/src/main/resources/logging.properties: -------------------------------------------------------------------------------- 1 | 2 | # Example Logging Configuration File 3 | # For more information see $JAVA_HOME/jre/lib/logging.properties 4 | 5 | # Send messages to the console 6 | handlers=io.helidon.common.HelidonConsoleHandler 7 | 8 | # HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread 9 | java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n 10 | 11 | # Global logging level. Can be overridden by specific loggers 12 | .level=INFO 13 | 14 | # Component specific log levels 15 | #io.helidon.webserver.level=INFO 16 | #io.helidon.config.level=INFO 17 | #io.helidon.security.level=INFO 18 | #io.helidon.common.level=INFO 19 | #io.netty.level=INFO 20 | -------------------------------------------------------------------------------- /micronaut-imperative/.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | .DS_Store 3 | .gradle 4 | build/ 5 | target/ 6 | out/ 7 | .idea 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .project 12 | .settings 13 | .classpath 14 | .factorypath 15 | -------------------------------------------------------------------------------- /micronaut-imperative/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/micronaut-imperative/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /micronaut-imperative/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -------------------------------------------------------------------------------- /micronaut-imperative/README.md: -------------------------------------------------------------------------------- 1 | ## Feature neo4j-bolt documentation 2 | 3 | - [Micronaut Neo4j Bolt Driver documentation](https://micronaut-projects.github.io/micronaut-neo4j/latest/guide/index.html) 4 | 5 | ## Feature http-client documentation 6 | 7 | - [Micronaut Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient) 8 | 9 | -------------------------------------------------------------------------------- /micronaut-imperative/micronaut-cli.yml: -------------------------------------------------------------------------------- 1 | applicationType: default 2 | defaultPackage: org.neo4j.examples.jvm.micronaut.reactive 3 | testFramework: junit 4 | sourceLanguage: java 5 | buildTool: maven 6 | features: [annotation-api, app-name, docker, http-client, java, java-application, junit, logback, maven, neo4j-bolt, netty-server, readme, shade, yaml] 7 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.imperative; 2 | 3 | import io.micronaut.runtime.Micronaut; 4 | 5 | public class Application { 6 | 7 | public static void main(String[] args) { 8 | Micronaut.run(Application.class, args); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.imperative.movies; 20 | 21 | import io.micronaut.core.annotation.Introspected; 22 | 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @Introspected 31 | public final class Actor { 32 | 33 | private final String name; 34 | 35 | private final List roles; 36 | 37 | public Actor(String name, final List roles) { 38 | this.name = name; 39 | this.roles = new ArrayList<>(roles); 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public List getRoles() { 47 | return Collections.unmodifiableList(roles); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.imperative.movies; 2 | 3 | import io.micronaut.http.MediaType; 4 | import io.micronaut.http.annotation.Controller; 5 | import io.micronaut.http.annotation.Get; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Michael J. Simons 11 | */ 12 | @Controller("/api/movies") 13 | public final class MoviesController { 14 | 15 | private final MovieRepository movieRepository; 16 | 17 | MoviesController(MovieRepository movieRepository) { 18 | this.movieRepository = movieRepository; 19 | } 20 | 21 | @Get(uris = { "", "/" }, produces = MediaType.APPLICATION_JSON) 22 | public List get() { 23 | return movieRepository.findAll(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.imperative.movies; 20 | 21 | import io.micronaut.http.HttpStatus; 22 | import io.micronaut.http.MediaType; 23 | import io.micronaut.http.annotation.Body; 24 | import io.micronaut.http.annotation.Controller; 25 | import io.micronaut.http.annotation.Post; 26 | import io.micronaut.http.annotation.Status; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @Controller("/api/people") 32 | public final class PeopleController { 33 | 34 | private final PeopleRepository peopleRepository; 35 | 36 | public PeopleController(PeopleRepository peopleRepository) { 37 | this.peopleRepository = peopleRepository; 38 | } 39 | 40 | @Post(produces = MediaType.APPLICATION_JSON) 41 | @Status(HttpStatus.CREATED) 42 | public Person createNewPerson(@Body Person newPersonCmd) { 43 | 44 | return peopleRepository.save(newPersonCmd); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.imperative.movies; 20 | 21 | import io.micronaut.core.annotation.Introspected; 22 | 23 | import com.fasterxml.jackson.annotation.JsonCreator; 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | /** 27 | * @author Michael J. Simons 28 | */ 29 | @Introspected 30 | public final class Person { 31 | 32 | private final Long id; 33 | 34 | private final String name; 35 | 36 | private Integer born; 37 | 38 | Person(Long id, String name, Integer born) { 39 | this.id = id; 40 | this.born = born; 41 | this.name = name; 42 | } 43 | 44 | @JsonCreator 45 | public Person(@JsonProperty("name") String name, @JsonProperty("born") Integer born) { 46 | this(null, name, born); 47 | } 48 | 49 | public Long getId() { 50 | return id; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public Integer getBorn() { 58 | return born; 59 | } 60 | 61 | public void setBorn(Integer born) { 62 | this.born = born; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.imperative.movies; 2 | 3 | import io.micronaut.core.annotation.Introspected; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @Introspected 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Integer born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = born; 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/java/org/neo4j/examples/jvm/micronaut/imperative/support/DefaultLivenessIndicator.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.imperative.support; 2 | 3 | import io.micronaut.health.HealthStatus; 4 | import io.micronaut.management.health.indicator.HealthIndicator; 5 | import io.micronaut.management.health.indicator.HealthResult; 6 | import io.micronaut.management.health.indicator.annotation.Liveness; 7 | import io.reactivex.Single; 8 | 9 | import org.reactivestreams.Publisher; 10 | 11 | /** 12 | * Seems that Micronaut needs at last one component annotated with {@link Liveness @Liveness}, otherwise live status is unknown. 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @Liveness 17 | public final class DefaultLivenessIndicator implements HealthIndicator { 18 | @Override 19 | public Publisher getResult() { 20 | return Single.just(HealthResult.builder("default").status(HealthStatus.UP).build()).toFlowable(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/resources/META-INF/native-image/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = --initialize-at-run-time=io.micronaut.neo4j.bolt.embedded.EmbeddedNeo4jServer,io.micronaut.neo4j.bolt.health.Neo4jHealthIndicator 2 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | micronaut: 2 | application: 3 | name: micronautReactive 4 | neo4j: 5 | username: neo4j 6 | password: secret 7 | uri: bolt://localhost:7687 8 | 9 | endpoints: 10 | all.path: /management 11 | health: 12 | enabled: true 13 | sensitive: false 14 | details-visible: anonymous 15 | -------------------------------------------------------------------------------- /micronaut-imperative/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 7 | 8 | %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /micronaut-imperative/src/test/java/org/neo4j/examples/jvm/micronaut/imperative/MicronautReactiveTest.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.imperative; 2 | 3 | import io.micronaut.runtime.EmbeddedApplication; 4 | import io.micronaut.test.extensions.junit5.annotation.MicronautTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.Assertions; 7 | 8 | import javax.inject.Inject; 9 | 10 | @MicronautTest 11 | public class MicronautReactiveTest { 12 | 13 | @Inject 14 | EmbeddedApplication application; 15 | 16 | @Test 17 | void testItWorks() { 18 | Assertions.assertTrue(application.isRunning()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /micronaut-reactive/.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | .DS_Store 3 | .gradle 4 | build/ 5 | target/ 6 | out/ 7 | .idea 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .project 12 | .settings 13 | .classpath 14 | .factorypath 15 | -------------------------------------------------------------------------------- /micronaut-reactive/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/micronaut-reactive/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /micronaut-reactive/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -------------------------------------------------------------------------------- /micronaut-reactive/README.md: -------------------------------------------------------------------------------- 1 | ## Feature neo4j-bolt documentation 2 | 3 | - [Micronaut Neo4j Bolt Driver documentation](https://micronaut-projects.github.io/micronaut-neo4j/latest/guide/index.html) 4 | 5 | ## Feature http-client documentation 6 | 7 | - [Micronaut Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient) 8 | 9 | -------------------------------------------------------------------------------- /micronaut-reactive/micronaut-cli.yml: -------------------------------------------------------------------------------- 1 | applicationType: default 2 | defaultPackage: org.neo4j.examples.jvm.micronaut.reactive 3 | testFramework: junit 4 | sourceLanguage: java 5 | buildTool: maven 6 | features: [annotation-api, app-name, docker, http-client, java, java-application, junit, logback, maven, neo4j-bolt, netty-server, readme, shade, yaml] 7 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive; 2 | 3 | import io.micronaut.runtime.Micronaut; 4 | 5 | public class Application { 6 | 7 | public static void main(String[] args) { 8 | Micronaut.run(Application.class, args); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 20 | 21 | import io.micronaut.core.annotation.Introspected; 22 | 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @Introspected 31 | public final class Actor { 32 | 33 | private final String name; 34 | 35 | private final List roles; 36 | 37 | public Actor(String name, final List roles) { 38 | this.name = name; 39 | this.roles = new ArrayList<>(roles); 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public List getRoles() { 47 | return Collections.unmodifiableList(roles); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 2 | 3 | import io.micronaut.http.MediaType; 4 | import io.micronaut.http.annotation.Controller; 5 | import io.micronaut.http.annotation.Get; 6 | import io.reactivex.Flowable; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | @Controller("/api/movies") 12 | public final class MoviesController { 13 | 14 | private final MovieRepository movieRepository; 15 | 16 | MoviesController(MovieRepository movieRepository) { 17 | this.movieRepository = movieRepository; 18 | } 19 | 20 | @Get(uris = { "", "/" }, produces = MediaType.APPLICATION_JSON) 21 | public Flowable get() { 22 | return movieRepository.findAll(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 20 | 21 | import io.micronaut.http.HttpStatus; 22 | import io.micronaut.http.MediaType; 23 | import io.micronaut.http.annotation.Body; 24 | import io.micronaut.http.annotation.Controller; 25 | import io.micronaut.http.annotation.Post; 26 | import io.micronaut.http.annotation.Status; 27 | import io.reactivex.Single; 28 | 29 | /** 30 | * @author Michael J. Simons 31 | */ 32 | @Controller("/api/people") 33 | public final class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @Post(produces = MediaType.APPLICATION_JSON) 42 | @Status(HttpStatus.CREATED) 43 | public Single createNewPerson(@Body Person newPersonCmd) { 44 | 45 | return peopleRepository.save(newPersonCmd); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 2 | 3 | import io.reactivex.Flowable; 4 | import io.reactivex.Observable; 5 | import io.reactivex.Single; 6 | 7 | import java.util.Map; 8 | 9 | import javax.inject.Singleton; 10 | 11 | import org.neo4j.driver.Driver; 12 | import org.neo4j.driver.types.Node; 13 | 14 | /** 15 | * @author Michael J. Simons 16 | */ 17 | @Singleton 18 | public class PeopleRepository { 19 | 20 | private final Driver driver; 21 | 22 | PeopleRepository(Driver driver) { 23 | this.driver = driver; 24 | } 25 | 26 | public Single save(Person person) { 27 | 28 | var query = "" 29 | + "MERGE (p:Person {name: $name})\n" 30 | + "SET p.born = $born\n" 31 | + "RETURN p\n"; 32 | var parameters = Map.of("name", person.getName(), "born", person.getBorn()); 33 | 34 | return Single.using( 35 | driver::rxSession, 36 | session -> Flowable.fromPublisher(session.writeTransaction(tx -> tx.run(query, parameters).records())) 37 | .map(r -> asPerson(r.get("p").asNode())) 38 | .singleOrError(), 39 | session -> Observable.fromPublisher(session.close()).subscribe() 40 | ); 41 | } 42 | 43 | static Person asPerson(Node personNode) { 44 | return new Person(personNode.id(), personNode.get("name").asString(), personNode.get("born").asInt()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 20 | 21 | import io.micronaut.core.annotation.Introspected; 22 | 23 | import com.fasterxml.jackson.annotation.JsonCreator; 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | /** 27 | * @author Michael J. Simons 28 | */ 29 | @Introspected 30 | public final class Person { 31 | 32 | private final Long id; 33 | 34 | private final String name; 35 | 36 | private Integer born; 37 | 38 | Person(Long id, String name, Integer born) { 39 | this.id = id; 40 | this.born = born; 41 | this.name = name; 42 | } 43 | 44 | @JsonCreator 45 | public Person(@JsonProperty("name") String name, @JsonProperty("born") Integer born) { 46 | this(null, name, born); 47 | } 48 | 49 | public Long getId() { 50 | return id; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public Integer getBorn() { 58 | return born; 59 | } 60 | 61 | public void setBorn(Integer born) { 62 | this.born = born; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive.movies; 2 | 3 | import io.micronaut.core.annotation.Introspected; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @Introspected 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Integer born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = born; 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/java/org/neo4j/examples/jvm/micronaut/reactive/support/DefaultLivenessIndicator.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive.support; 2 | 3 | import io.micronaut.health.HealthStatus; 4 | import io.micronaut.management.health.indicator.HealthIndicator; 5 | import io.micronaut.management.health.indicator.HealthResult; 6 | import io.micronaut.management.health.indicator.annotation.Liveness; 7 | import io.reactivex.Single; 8 | 9 | import org.reactivestreams.Publisher; 10 | 11 | /** 12 | * Seems that Micronaut needs at last one component annotated with {@link Liveness @Liveness}, otherwise live status is unknown. 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @Liveness 17 | public final class DefaultLivenessIndicator implements HealthIndicator { 18 | @Override 19 | public Publisher getResult() { 20 | return Single.just(HealthResult.builder("default").status(HealthStatus.UP).build()).toFlowable(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/resources/META-INF/native-image/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = --initialize-at-run-time=io.micronaut.neo4j.bolt.embedded.EmbeddedNeo4jServer,io.micronaut.neo4j.bolt.health.Neo4jHealthIndicator 2 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | micronaut: 2 | application: 3 | name: micronautReactive 4 | neo4j: 5 | username: neo4j 6 | password: secret 7 | uri: bolt://localhost:7687 8 | 9 | endpoints: 10 | all.path: /management 11 | health: 12 | enabled: true 13 | sensitive: false 14 | details-visible: anonymous 15 | -------------------------------------------------------------------------------- /micronaut-reactive/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 7 | 8 | %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /micronaut-reactive/src/test/java/org/neo4j/examples/jvm/micronaut/reactive/MicronautReactiveTest.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.micronaut.reactive; 2 | 3 | import io.micronaut.runtime.EmbeddedApplication; 4 | import io.micronaut.test.extensions.junit5.annotation.MicronautTest; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.Assertions; 7 | 8 | import javax.inject.Inject; 9 | 10 | @MicronautTest 11 | public class MicronautReactiveTest { 12 | 13 | @Inject 14 | EmbeddedApplication application; 15 | 16 | @Test 17 | void testItWorks() { 18 | Assertions.assertTrue(application.isRunning()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /quarkus-imperative/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /quarkus-imperative/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | # Eclipse 8 | .project 9 | .classpath 10 | .settings/ 11 | bin/ 12 | 13 | # IntelliJ 14 | .idea 15 | *.ipr 16 | *.iml 17 | *.iws 18 | 19 | # NetBeans 20 | nb-configuration.xml 21 | 22 | # Visual Studio Code 23 | .vscode 24 | .factorypath 25 | 26 | # OSX 27 | .DS_Store 28 | 29 | # Vim 30 | *.swp 31 | *.swo 32 | 33 | # patch 34 | *.orig 35 | *.rej 36 | 37 | -------------------------------------------------------------------------------- /quarkus-imperative/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/quarkus-imperative/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /quarkus-imperative/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /quarkus-imperative/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-imperative project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application can be packaged using: 17 | ```shell script 18 | ./mvnw package 19 | ``` 20 | It produces the `quarkus-imperative-1.0.0-runner.jar` file in the `/target` directory. 21 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 22 | 23 | If you want to build an _über-jar_, execute the following command: 24 | ```shell script 25 | ./mvnw package -Dquarkus.package.type=uber-jar 26 | ``` 27 | 28 | The application is now runnable using `java -jar target/quarkus-imperative-1.0.0-runner.jar`. 29 | 30 | ## Creating a native executable 31 | 32 | You can create a native executable using: 33 | ```shell script 34 | ./mvnw package -Pnative 35 | ``` 36 | 37 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 38 | ```shell script 39 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 40 | ``` 41 | 42 | You can then execute your native executable with: `./target/quarkus-imperative-1.0.0-runner` 43 | 44 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 45 | 46 | # Command Mode 47 | 48 | Guide: https://quarkus.io/guides/command-mode-reference 49 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/docker/Dockerfile.native: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode 3 | # 4 | # Before building the container image run: 5 | # 6 | # ./mvnw package -Pnative 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/code-with-quarkus . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3 18 | WORKDIR /work/ 19 | RUN chown 1001 /work \ 20 | && chmod "g+rwX" /work \ 21 | && chown 1001:root /work 22 | COPY --chown=1001:root target/*-runner /work/application 23 | 24 | EXPOSE 8080 25 | USER 1001 26 | 27 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] 28 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.imperative; 2 | 3 | import io.quarkus.runtime.Quarkus; 4 | import io.quarkus.runtime.annotations.QuarkusMain; 5 | 6 | @QuarkusMain 7 | public class Application { 8 | 9 | public static void main(String... args) { 10 | Quarkus.run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | /** 26 | * @author Michael J. Simons 27 | */ 28 | public final class Actor { 29 | 30 | private final String name; 31 | 32 | private final List roles; 33 | 34 | public Actor(String name, final List roles) { 35 | this.name = name; 36 | this.roles = new ArrayList<>(roles); 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public List getRoles() { 44 | return Collections.unmodifiableList(roles); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/movies/MovieResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 20 | 21 | import java.util.List; 22 | 23 | import javax.enterprise.context.RequestScoped; 24 | import javax.inject.Inject; 25 | import javax.ws.rs.GET; 26 | import javax.ws.rs.Path; 27 | import javax.ws.rs.Produces; 28 | import javax.ws.rs.core.MediaType; 29 | 30 | /** 31 | * @author Michael J. Simons 32 | */ 33 | @RequestScoped 34 | @Path("/api/movies") 35 | public class MovieResource { 36 | 37 | private final MovieRepository movieRepository; 38 | 39 | @Inject 40 | public MovieResource(MovieRepository movieRepository) { 41 | this.movieRepository = movieRepository; 42 | } 43 | 44 | @GET 45 | @Produces(MediaType.APPLICATION_JSON) 46 | public List getMovies() { 47 | 48 | return movieRepository.findAll(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/movies/PeopleResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 20 | 21 | import javax.enterprise.context.RequestScoped; 22 | import javax.ws.rs.POST; 23 | import javax.ws.rs.Path; 24 | import javax.ws.rs.Produces; 25 | import javax.ws.rs.core.MediaType; 26 | import javax.ws.rs.core.Response; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RequestScoped 32 | @Path("/api/people") 33 | public class PeopleResource { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleResource(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @POST 42 | @Produces(MediaType.APPLICATION_JSON) 43 | public Response createNewPerson(Person newPerson) { 44 | 45 | var savedPerson = peopleRepository.save(newPerson); 46 | return Response.status(Response.Status.CREATED).entity(savedPerson).build(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 20 | 21 | import javax.json.bind.annotation.JsonbCreator; 22 | import javax.json.bind.annotation.JsonbProperty; 23 | 24 | /** 25 | * @author Michael J. Simons 26 | */ 27 | public final class Person { 28 | 29 | private final Long id; 30 | 31 | private final String name; 32 | 33 | private Integer born; 34 | 35 | Person(Long id, String name, Integer born) { 36 | this.id = id; 37 | this.born = born; 38 | this.name = name; 39 | } 40 | 41 | @JsonbCreator 42 | public Person(@JsonbProperty("name") String name, @JsonbProperty("born") Integer born) { 43 | this(null, name, born); 44 | } 45 | 46 | public Long getId() { 47 | return id; 48 | } 49 | 50 | public String getName() { 51 | return name; 52 | } 53 | 54 | public Integer getBorn() { 55 | return born; 56 | } 57 | 58 | public void setBorn(Integer born) { 59 | this.born = born; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/java/org/neo4j/examples/jvm/quarkus/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /quarkus-imperative/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.neo4j.uri=bolt://localhost:7687 2 | quarkus.neo4j.authentication.username=neo4j 3 | quarkus.neo4j.authentication.password=secret 4 | 5 | quarkus.smallrye-health.root-path=/management/health 6 | quarkus.smallrye-health.liveness-path=liveness 7 | quarkus.smallrye-health.readiness-path=readiness 8 | -------------------------------------------------------------------------------- /quarkus-imperative/src/test/java/org/neo4j/examples/jvm/quarkus/imperative/movies/EmbeddedNeo4jTestResource.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.imperative.movies; 2 | 3 | import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; 4 | 5 | import java.util.Map; 6 | 7 | import org.neo4j.harness.Neo4j; 8 | import org.neo4j.harness.Neo4jBuilders; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | public final class EmbeddedNeo4jTestResource implements QuarkusTestResourceLifecycleManager { 14 | 15 | private String fixture; 16 | private Neo4j embeddedDatabaseServer; 17 | 18 | @Override 19 | public void init(Map initArgs) { 20 | this.fixture = initArgs.getOrDefault("fixture", ""); 21 | } 22 | 23 | @Override 24 | public Map start() { 25 | 26 | this.embeddedDatabaseServer = Neo4jBuilders.newInProcessBuilder() 27 | .withDisabledServer() 28 | .withFixture(fixture) 29 | .build(); 30 | 31 | return Map.of( 32 | "quarkus.neo4j.uri", this.embeddedDatabaseServer.boltURI().toString(), 33 | "quarkus.neo4j.authentication.username", "neo4j", 34 | "quarkus.neo4j.authentication.password", "n/a" 35 | ); 36 | } 37 | 38 | @Override 39 | public void stop() { 40 | 41 | this.embeddedDatabaseServer.close(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /quarkus-ogm/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /quarkus-ogm/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | # Eclipse 8 | .project 9 | .classpath 10 | .settings/ 11 | bin/ 12 | 13 | # IntelliJ 14 | .idea 15 | *.ipr 16 | *.iml 17 | *.iws 18 | 19 | # NetBeans 20 | nb-configuration.xml 21 | 22 | # Visual Studio Code 23 | .vscode 24 | .factorypath 25 | 26 | # OSX 27 | .DS_Store 28 | 29 | # Vim 30 | *.swp 31 | *.swo 32 | 33 | # patch 34 | *.orig 35 | *.rej 36 | 37 | -------------------------------------------------------------------------------- /quarkus-ogm/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/quarkus-ogm/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /quarkus-ogm/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /quarkus-ogm/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-ogm Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 26 | 27 | If you want to build an _über-jar_, execute the following command: 28 | ```shell script 29 | ./mvnw package -Dquarkus.package.type=uber-jar 30 | ``` 31 | 32 | The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. 33 | 34 | ## Creating a native executable 35 | 36 | You can create a native executable using: 37 | ```shell script 38 | ./mvnw package -Pnative 39 | ``` 40 | 41 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 42 | ```shell script 43 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 44 | ``` 45 | 46 | You can then execute your native executable with: `./target/quarkus-ogm-1.0.0-SNAPSHOT-runner` 47 | 48 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling. -------------------------------------------------------------------------------- /quarkus-ogm/src/main/docker/Dockerfile.native: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. 3 | # 4 | # Before building the container image run: 5 | # 6 | # ./mvnw package -Pnative 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-ogm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-ogm 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 18 | WORKDIR /work/ 19 | RUN chown 1001 /work \ 20 | && chmod "g+rwX" /work \ 21 | && chown 1001:root /work 22 | COPY --chown=1001:root target/*-runner /work/application 23 | 24 | EXPOSE 8080 25 | USER 1001 26 | 27 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] 28 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.ogm; 2 | 3 | import io.quarkus.runtime.Quarkus; 4 | import io.quarkus.runtime.annotations.QuarkusMain; 5 | 6 | @QuarkusMain 7 | public class Application { 8 | 9 | public static void main(String... args) { 10 | Quarkus.run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2022 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.ogm.movies; 20 | 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import javax.json.bind.annotation.JsonbProperty; 25 | import javax.json.bind.annotation.JsonbTransient; 26 | 27 | import org.neo4j.ogm.annotation.EndNode; 28 | import org.neo4j.ogm.annotation.GeneratedValue; 29 | import org.neo4j.ogm.annotation.Id; 30 | import org.neo4j.ogm.annotation.RelationshipEntity; 31 | import org.neo4j.ogm.annotation.StartNode; 32 | 33 | /** 34 | * @author Michael J. Simons 35 | */ 36 | @RelationshipEntity("ACTED_IN") 37 | public final class Actor { 38 | 39 | @Id @GeneratedValue 40 | @JsonbTransient 41 | private Long id; 42 | 43 | private List roles; 44 | 45 | @StartNode 46 | @JsonbTransient 47 | private Person person; 48 | 49 | @EndNode private Movie movie; 50 | 51 | @JsonbProperty 52 | public String getName() { 53 | return person.getName(); 54 | } 55 | 56 | public List getRoles() { 57 | return Collections.unmodifiableList(roles); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2022 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.ogm.movies; 20 | 21 | import java.util.Collection; 22 | 23 | import javax.enterprise.context.ApplicationScoped; 24 | 25 | import org.neo4j.ogm.session.SessionFactory; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @ApplicationScoped 31 | public class MovieRepository { 32 | 33 | private final SessionFactory sessionFactory; 34 | 35 | MovieRepository(SessionFactory sessionFactory) { 36 | this.sessionFactory = sessionFactory; 37 | } 38 | 39 | public Collection findAll() { 40 | 41 | return sessionFactory.openSession().loadAll(Movie.class); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/movies/MovieResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2022 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.ogm.movies; 20 | 21 | import java.util.Collection; 22 | import java.util.List; 23 | 24 | import javax.enterprise.context.RequestScoped; 25 | import javax.inject.Inject; 26 | import javax.ws.rs.GET; 27 | import javax.ws.rs.Path; 28 | import javax.ws.rs.Produces; 29 | import javax.ws.rs.core.MediaType; 30 | 31 | /** 32 | * @author Michael J. Simons 33 | */ 34 | @RequestScoped 35 | @Path("/api/movies") 36 | public class MovieResource { 37 | 38 | private final MovieRepository movieRepository; 39 | 40 | @Inject 41 | public MovieResource(MovieRepository movieRepository) { 42 | this.movieRepository = movieRepository; 43 | } 44 | 45 | @GET 46 | @Produces(MediaType.APPLICATION_JSON) 47 | public Collection getMovies() { 48 | 49 | return movieRepository.findAll(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.ogm.movies; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | 5 | import org.neo4j.ogm.session.Session; 6 | import org.neo4j.ogm.session.SessionFactory; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | @ApplicationScoped 12 | public class PeopleRepository { 13 | 14 | private final SessionFactory sessionFactory; 15 | 16 | public PeopleRepository(SessionFactory sessionFactory) { 17 | this.sessionFactory = sessionFactory; 18 | } 19 | 20 | Person save(Person person) { 21 | 22 | var session = sessionFactory.openSession(); 23 | session.save(person); 24 | return person; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/java/org/neo4j/examples/jvm/quarkus/ogm/movies/PeopleResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2022 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.ogm.movies; 20 | 21 | import javax.enterprise.context.RequestScoped; 22 | import javax.ws.rs.POST; 23 | import javax.ws.rs.Path; 24 | import javax.ws.rs.Produces; 25 | import javax.ws.rs.core.MediaType; 26 | import javax.ws.rs.core.Response; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RequestScoped 32 | @Path("/api/people") 33 | public class PeopleResource { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleResource(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @POST 42 | @Produces(MediaType.APPLICATION_JSON) 43 | public Response createNewPerson(Person newPerson) { 44 | 45 | var savedPerson = peopleRepository.save(newPerson); 46 | return Response.status(Response.Status.CREATED).entity(savedPerson).build(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /quarkus-ogm/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.neo4j.uri=bolt://localhost:7687 2 | quarkus.neo4j.authentication.username=neo4j 3 | quarkus.neo4j.authentication.password=secret 4 | 5 | org.neo4j.ogm.use-strict-querying=true 6 | org.neo4j.ogm.use-native-types=true 7 | org.neo4j.ogm.base-packages=org.neo4j.examples.jvm.quarkus.ogm.movies 8 | 9 | quarkus.smallrye-health.root-path=/management/health 10 | quarkus.smallrye-health.liveness-path=liveness 11 | quarkus.smallrye-health.readiness-path=readiness 12 | -------------------------------------------------------------------------------- /quarkus-reactive/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /quarkus-reactive/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | # Eclipse 8 | .project 9 | .classpath 10 | .settings/ 11 | bin/ 12 | 13 | # IntelliJ 14 | .idea 15 | *.ipr 16 | *.iml 17 | *.iws 18 | 19 | # NetBeans 20 | nb-configuration.xml 21 | 22 | # Visual Studio Code 23 | .vscode 24 | .factorypath 25 | 26 | # OSX 27 | .DS_Store 28 | 29 | # Vim 30 | *.swp 31 | *.swo 32 | 33 | # patch 34 | *.orig 35 | *.rej 36 | 37 | -------------------------------------------------------------------------------- /quarkus-reactive/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/quarkus-reactive/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /quarkus-reactive/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /quarkus-reactive/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-reactive project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application can be packaged using: 17 | ```shell script 18 | ./mvnw package 19 | ``` 20 | It produces the `quarkus-reactive-1.0.0-SNAPSHOT-runner.jar` file in the `/target` directory. 21 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 22 | 23 | If you want to build an _über-jar_, execute the following command: 24 | ```shell script 25 | ./mvnw package -Dquarkus.package.type=uber-jar 26 | ``` 27 | 28 | The application is now runnable using `java -jar target/quarkus-reactive-1.0.0-SNAPSHOT-runner.jar`. 29 | 30 | ## Creating a native executable 31 | 32 | You can create a native executable using: 33 | ```shell script 34 | ./mvnw package -Pnative 35 | ``` 36 | 37 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 38 | ```shell script 39 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 40 | ``` 41 | 42 | You can then execute your native executable with: `./target/quarkus-reactive-1.0.0-SNAPSHOT-runner` 43 | 44 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 45 | 46 | # Command Mode 47 | 48 | Guide: https://quarkus.io/guides/command-mode-reference 49 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/docker/Dockerfile.native: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode 3 | # 4 | # Before building the container image run: 5 | # 6 | # ./mvnw package -Pnative 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/code-with-quarkus . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3 18 | WORKDIR /work/ 19 | RUN chown 1001 /work \ 20 | && chmod "g+rwX" /work \ 21 | && chown 1001:root /work 22 | COPY --chown=1001:root target/*-runner /work/application 23 | 24 | EXPOSE 8080 25 | USER 1001 26 | 27 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] 28 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.reactive; 2 | 3 | import io.quarkus.runtime.Quarkus; 4 | import io.quarkus.runtime.annotations.QuarkusMain; 5 | 6 | @QuarkusMain 7 | public class Application { 8 | 9 | public static void main(String... args) { 10 | Quarkus.run(args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | /** 26 | * @author Michael J. Simons 27 | */ 28 | public final class Actor { 29 | 30 | private final String name; 31 | 32 | private final List roles; 33 | 34 | public Actor(String name, final List roles) { 35 | this.name = name; 36 | this.roles = new ArrayList<>(roles); 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public List getRoles() { 44 | return Collections.unmodifiableList(roles); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/movies/MovieResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 20 | 21 | import io.smallrye.mutiny.Multi; 22 | 23 | import javax.enterprise.context.RequestScoped; 24 | import javax.inject.Inject; 25 | import javax.ws.rs.GET; 26 | import javax.ws.rs.Path; 27 | import javax.ws.rs.Produces; 28 | import javax.ws.rs.core.MediaType; 29 | 30 | /** 31 | * @author Michael J. Simons 32 | */ 33 | @RequestScoped 34 | @Path("/api/movies") 35 | public class MovieResource { 36 | 37 | private final MovieRepository movieRepository; 38 | 39 | @Inject 40 | public MovieResource(MovieRepository movieRepository) { 41 | this.movieRepository = movieRepository; 42 | } 43 | 44 | @GET 45 | @Produces(MediaType.APPLICATION_JSON) 46 | public Multi getMovies() { 47 | 48 | return movieRepository.findAll(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/movies/PeopleResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 20 | 21 | import io.smallrye.mutiny.Uni; 22 | 23 | import javax.enterprise.context.RequestScoped; 24 | import javax.ws.rs.POST; 25 | import javax.ws.rs.Path; 26 | import javax.ws.rs.Produces; 27 | import javax.ws.rs.core.MediaType; 28 | import javax.ws.rs.core.Response; 29 | 30 | /** 31 | * @author Michael J. Simons 32 | */ 33 | @RequestScoped 34 | @Path("/api/people") 35 | public class PeopleResource { 36 | 37 | private final PeopleRepository peopleRepository; 38 | 39 | public PeopleResource(PeopleRepository peopleRepository) { 40 | this.peopleRepository = peopleRepository; 41 | } 42 | 43 | @POST 44 | @Produces(MediaType.APPLICATION_JSON) 45 | public Uni createNewPerson(Person newPerson) { 46 | 47 | var savedPerson = peopleRepository.save(newPerson); 48 | return savedPerson.map(entity -> Response.status(Response.Status.CREATED).entity(entity).build()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 20 | 21 | import javax.json.bind.annotation.JsonbCreator; 22 | import javax.json.bind.annotation.JsonbProperty; 23 | 24 | /** 25 | * @author Michael J. Simons 26 | */ 27 | public final class Person { 28 | 29 | private final Long id; 30 | 31 | private final String name; 32 | 33 | private Integer born; 34 | 35 | Person(Long id, String name, Integer born) { 36 | this.id = id; 37 | this.born = born; 38 | this.name = name; 39 | } 40 | 41 | @JsonbCreator 42 | public Person(@JsonbProperty("name") String name, @JsonbProperty("born") Integer born) { 43 | this(null, name, born); 44 | } 45 | 46 | public Long getId() { 47 | return id; 48 | } 49 | 50 | public String getName() { 51 | return name; 52 | } 53 | 54 | public Integer getBorn() { 55 | return born; 56 | } 57 | 58 | public void setBorn(Integer born) { 59 | this.born = born; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/java/org/neo4j/examples/jvm/quarkus/reactive/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /quarkus-reactive/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.neo4j.uri=bolt://localhost:7687 2 | quarkus.neo4j.authentication.username=neo4j 3 | quarkus.neo4j.authentication.password=secret 4 | 5 | quarkus.smallrye-health.root-path=/management/health 6 | quarkus.smallrye-health.liveness-path=liveness 7 | quarkus.smallrye-health.readiness-path=readiness 8 | -------------------------------------------------------------------------------- /quarkus-reactive/src/test/java/org/neo4j/examples/jvm/quarkus/reactive/movies/EmbeddedNeo4jTestResource.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.quarkus.reactive.movies; 2 | 3 | import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; 4 | 5 | import java.util.Map; 6 | 7 | import org.neo4j.harness.Neo4j; 8 | import org.neo4j.harness.Neo4jBuilders; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | public final class EmbeddedNeo4jTestResource implements QuarkusTestResourceLifecycleManager { 14 | 15 | private String fixture; 16 | private Neo4j embeddedDatabaseServer; 17 | 18 | @Override 19 | public void init(Map initArgs) { 20 | this.fixture = initArgs.getOrDefault("fixture", ""); 21 | } 22 | 23 | @Override 24 | public Map start() { 25 | 26 | this.embeddedDatabaseServer = Neo4jBuilders.newInProcessBuilder() 27 | .withDisabledServer() 28 | .withFixture(fixture) 29 | .build(); 30 | 31 | return Map.of( 32 | "quarkus.neo4j.uri", this.embeddedDatabaseServer.boltURI().toString(), 33 | "quarkus.neo4j.authentication.username", "neo4j", 34 | "quarkus.neo4j.authentication.password", "n/a" 35 | ); 36 | } 37 | 38 | @Override 39 | public void stop() { 40 | 41 | this.embeddedDatabaseServer.close(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-boot23-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | import java.util.stream.Stream; 6 | import java.util.stream.StreamSupport; 7 | 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author Michael J. Simons 15 | */ 16 | @RestController 17 | @RequestMapping("/api/movies") 18 | public final class MoviesController { 19 | 20 | private final MovieRepository movieRepository; 21 | 22 | MoviesController(MovieRepository movieRepository) { 23 | this.movieRepository = movieRepository; 24 | } 25 | 26 | @GetMapping({ "", "/" }) 27 | public List get() { 28 | return StreamSupport.stream(movieRepository.findAll(Sort.by("title").ascending()).spliterator(), false).collect( 29 | Collectors.toList()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.Neo4jRepository; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person.name AS name, person.born AS born, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.neo4j.ogm.annotation.GeneratedValue; 22 | import org.neo4j.ogm.annotation.Id; 23 | import org.neo4j.ogm.annotation.NodeEntity; 24 | 25 | import com.fasterxml.jackson.annotation.JsonCreator; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @NodeEntity 31 | public final class Person { 32 | 33 | @Id @GeneratedValue 34 | private Long id; 35 | 36 | private String name; 37 | 38 | private Integer born; 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this.name = name; 43 | this.born = born; 44 | } 45 | 46 | /** 47 | * Make OGM happy. 48 | */ 49 | Person() { 50 | } 51 | 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public Integer getBorn() { 61 | return born; 62 | } 63 | 64 | public void setBorn(Integer born) { 65 | this.born = born; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.springframework.data.neo4j.annotation.QueryResult; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @QueryResult 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Long born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = Math.toIntExact(born); 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | org.neo4j.driver.uri=bolt://localhost:7687 2 | org.neo4j.driver.authentication.username=neo4j 3 | org.neo4j.driver.authentication.password=secret 4 | 5 | logging.level.org.neo4j.ogm = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | 11 | -------------------------------------------------------------------------------- /spring-boot23-with-sdn-ogm/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-boot24-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | import java.util.stream.Stream; 6 | import java.util.stream.StreamSupport; 7 | 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author Michael J. Simons 15 | */ 16 | @RestController 17 | @RequestMapping("/api/movies") 18 | public final class MoviesController { 19 | 20 | private final MovieRepository movieRepository; 21 | 22 | MoviesController(MovieRepository movieRepository) { 23 | this.movieRepository = movieRepository; 24 | } 25 | 26 | @GetMapping({ "", "/" }) 27 | public List get() { 28 | return StreamSupport.stream(movieRepository.findAll(Sort.by("title").ascending()).spliterator(), false).collect( 29 | Collectors.toList()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.Neo4jRepository; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person.name AS name, person.born AS born, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.neo4j.ogm.annotation.GeneratedValue; 22 | import org.neo4j.ogm.annotation.Id; 23 | import org.neo4j.ogm.annotation.NodeEntity; 24 | 25 | import com.fasterxml.jackson.annotation.JsonCreator; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @NodeEntity 31 | public final class Person { 32 | 33 | @Id @GeneratedValue 34 | private Long id; 35 | 36 | private String name; 37 | 38 | private Integer born; 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this.name = name; 43 | this.born = born; 44 | } 45 | 46 | /** 47 | * Make OGM happy. 48 | */ 49 | Person() { 50 | } 51 | 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public Integer getBorn() { 61 | return born; 62 | } 63 | 64 | public void setBorn(Integer born) { 65 | this.born = born; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.springframework.data.neo4j.annotation.QueryResult; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @QueryResult 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Long born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = Math.toIntExact(born); 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.neo4j.ogm = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | 11 | -------------------------------------------------------------------------------- /spring-boot24-with-sdn-ogm/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-boot26-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.actuate.autoconfigure.metrics.data.RepositoryMetricsAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | // SDN Neumann does not provide the necessary infrastructure for the repository metrics to work, so this must be disabled. 8 | @SpringBootApplication(exclude = RepositoryMetricsAutoConfiguration.class) 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | import java.util.stream.Stream; 6 | import java.util.stream.StreamSupport; 7 | 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author Michael J. Simons 15 | */ 16 | @RestController 17 | @RequestMapping("/api/movies") 18 | public final class MoviesController { 19 | 20 | private final MovieRepository movieRepository; 21 | 22 | MoviesController(MovieRepository movieRepository) { 23 | this.movieRepository = movieRepository; 24 | } 25 | 26 | @GetMapping({ "", "/" }) 27 | public List get() { 28 | return StreamSupport.stream(movieRepository.findAll(Sort.by("title").ascending()).spliterator(), false).collect( 29 | Collectors.toList()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.Neo4jRepository; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person.name AS name, person.born AS born, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.neo4j.ogm.annotation.GeneratedValue; 22 | import org.neo4j.ogm.annotation.Id; 23 | import org.neo4j.ogm.annotation.NodeEntity; 24 | 25 | import com.fasterxml.jackson.annotation.JsonCreator; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @NodeEntity 31 | public final class Person { 32 | 33 | @Id @GeneratedValue 34 | private Long id; 35 | 36 | private String name; 37 | 38 | private Integer born; 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this.name = name; 43 | this.born = born; 44 | } 45 | 46 | /** 47 | * Make OGM happy. 48 | */ 49 | Person() { 50 | } 51 | 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public Integer getBorn() { 61 | return born; 62 | } 63 | 64 | public void setBorn(Integer born) { 65 | this.born = born; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.springframework.data.neo4j.annotation.QueryResult; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @QueryResult 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Long born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = Math.toIntExact(born); 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.neo4j.ogm = info 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-boot26-with-sdn-ogm/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-boot27-with-sdn-ogm/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.actuate.autoconfigure.metrics.data.RepositoryMetricsAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | // SDN Neumann does not provide the necessary infrastructure for the repository metrics to work, so this must be disabled. 8 | @SpringBootApplication(exclude = RepositoryMetricsAutoConfiguration.class) 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import java.util.Optional; 22 | 23 | import org.springframework.data.neo4j.repository.Neo4jRepository; 24 | 25 | /** 26 | * @author Michael J. Simons 27 | */ 28 | interface MovieRepository extends Neo4jRepository { 29 | 30 | Optional findByTitle(String s); 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | import java.util.stream.Stream; 6 | import java.util.stream.StreamSupport; 7 | 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author Michael J. Simons 15 | */ 16 | @RestController 17 | @RequestMapping("/api/movies") 18 | public final class MoviesController { 19 | 20 | private final MovieRepository movieRepository; 21 | 22 | MoviesController(MovieRepository movieRepository) { 23 | this.movieRepository = movieRepository; 24 | } 25 | 26 | @GetMapping({ "", "/" }) 27 | public List get() { 28 | return StreamSupport.stream(movieRepository.findAll(Sort.by("title").ascending()).spliterator(), false).collect( 29 | Collectors.toList()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.Neo4jRepository; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person.name AS name, person.born AS born, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.neo4j.ogm.annotation.GeneratedValue; 22 | import org.neo4j.ogm.annotation.Id; 23 | import org.neo4j.ogm.annotation.NodeEntity; 24 | 25 | import com.fasterxml.jackson.annotation.JsonCreator; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @NodeEntity 31 | public final class Person { 32 | 33 | @Id @GeneratedValue 34 | private Long id; 35 | 36 | private String name; 37 | 38 | private Integer born; 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this.name = name; 43 | this.born = born; 44 | } 45 | 46 | /** 47 | * Make OGM happy. 48 | */ 49 | Person() { 50 | } 51 | 52 | public Long getId() { 53 | return id; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public Integer getBorn() { 61 | return born; 62 | } 63 | 64 | public void setBorn(Integer born) { 65 | this.born = born; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.springframework.data.neo4j.annotation.QueryResult; 8 | 9 | /** 10 | * This is a DTO based projection, containing a couple of additional details, 11 | * like the list of movies a person acted in, the movies they direct and which other 12 | * people they acted with 13 | * 14 | * @author Michael J. Simons 15 | */ 16 | @QueryResult 17 | public final class PersonDetails { 18 | 19 | private final String name; 20 | 21 | private final Integer born; 22 | 23 | private final List actedIn; 24 | 25 | private final List directed; 26 | 27 | private final List related; 28 | 29 | public PersonDetails(String name, Long born, List actedIn, 30 | List directed, List related) { 31 | this.name = name; 32 | this.born = Math.toIntExact(born); 33 | this.actedIn = new ArrayList<>(actedIn); 34 | this.directed = new ArrayList<>(directed); 35 | this.related = new ArrayList<>(related); 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public Integer getBorn() { 43 | return born; 44 | } 45 | 46 | public List getActedIn() { 47 | return Collections.unmodifiableList(actedIn); 48 | } 49 | 50 | public List getDirected() { 51 | return Collections.unmodifiableList(directed); 52 | } 53 | 54 | public List getRelated() { 55 | return Collections.unmodifiableList(related); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.neo4j.ogm = info 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-boot27-with-sdn-ogm/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED --add-exports java.base/java.lang=ALL-UNNAMED 2 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-data-imperative-module-path/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-data-imperative-module-path/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adoptopenjdk:16-jdk as builder 2 | WORKDIR application 3 | ARG JAR_FILE=target/*.jar 4 | ARG APP_ONLY_JAR_FILE=target/*.jar.original 5 | COPY ${JAR_FILE} full.jar 6 | COPY ${APP_ONLY_JAR_FILE} application.jar 7 | RUN java -Djarmode=layertools -jar full.jar extract 8 | 9 | FROM adoptopenjdk:16-jdk 10 | WORKDIR application 11 | COPY --from=builder application/dependencies/BOOT-INF/lib ./lib 12 | COPY --from=builder application/application.jar ./ 13 | ENTRYPOINT ["java", "-p", ".:lib", "-m", "sdn.mp/org.neo4j.examples.jvm.spring.data.imperative.Application"] 14 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module sdn.mp { 2 | 3 | requires com.fasterxml.jackson.annotation; 4 | requires com.fasterxml.jackson.databind; 5 | 6 | // The Cypher-DSL provides a valid Java module. 7 | // SDN 6.1 is not build as Multi-Release jar and thus does 8 | // not contain a module-info which could require it, therefore we 9 | // must do this manually. 10 | requires org.neo4j.cypherdsl.core; 11 | 12 | requires spring.beans; 13 | requires spring.boot; 14 | requires spring.boot.autoconfigure; 15 | requires spring.data.commons; 16 | requires spring.data.neo4j; 17 | requires spring.web; 18 | requires spring.webmvc; 19 | 20 | // Otherwise this is not visible to Spring Boot 21 | requires org.apache.tomcat.embed.core; 22 | 23 | // I want to have reflection only against selected modules 24 | opens org.neo4j.examples.jvm.spring.data.imperative to spring.core; 25 | opens org.neo4j.examples.jvm.spring.data.imperative.movies to spring.core, com.fasterxml.jackson.databind; 26 | 27 | // We can be more selective here as well, but the application in the root package and the movies 28 | // will be public api. 29 | exports org.neo4j.examples.jvm.spring.data.imperative; 30 | exports org.neo4j.examples.jvm.spring.data.imperative.movies; 31 | } -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Sort; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | @RestController 14 | @RequestMapping("/api/movies") 15 | public final class MoviesController { 16 | 17 | private final MovieRepository movieRepository; 18 | 19 | MoviesController(MovieRepository movieRepository) { 20 | this.movieRepository = movieRepository; 21 | } 22 | 23 | @GetMapping({ "", "/" }) 24 | public List get() { 25 | return movieRepository.findAll(Sort.by("title").ascending()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.repository.Neo4jRepository; 6 | import org.springframework.data.neo4j.repository.query.Query; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import com.fasterxml.jackson.annotation.JsonCreator; 22 | import org.springframework.data.annotation.PersistenceConstructor; 23 | import org.springframework.data.neo4j.core.schema.GeneratedValue; 24 | import org.springframework.data.neo4j.core.schema.Id; 25 | import org.springframework.data.neo4j.core.schema.Node; 26 | 27 | /** 28 | * @author Michael J. Simons 29 | */ 30 | @Node 31 | public record Person( 32 | 33 | @Id @GeneratedValue 34 | Long id, 35 | 36 | String name, 37 | 38 | Integer born 39 | ) { 40 | 41 | @PersistenceConstructor 42 | public Person { 43 | } 44 | 45 | @JsonCreator 46 | public Person(String name, Integer born) { 47 | this(null, name, born); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * This is a DTO based projection, containing a couple of additional details, 7 | * like the list of movies a person acted in, the movies they direct and which other 8 | * people they acted with 9 | * 10 | * @author Michael J. Simons 11 | */ 12 | public record PersonDetails ( 13 | 14 | String name, 15 | 16 | Integer born, 17 | 18 | List actedIn, 19 | 20 | List directed, 21 | 22 | List related) { 23 | } 24 | -------------------------------------------------------------------------------- /spring-data-imperative-module-path/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.springframework.data.neo4j.cypher = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-data-imperative-native/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-data-imperative-native/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-data-imperative-native/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-data-imperative-native/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Sort; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | @RestController 14 | @RequestMapping("/api/movies") 15 | public final class MoviesController { 16 | 17 | private final MovieRepository movieRepository; 18 | 19 | MoviesController(MovieRepository movieRepository) { 20 | this.movieRepository = movieRepository; 21 | } 22 | 23 | @GetMapping({ "", "/" }) 24 | public List get() { 25 | return movieRepository.findAll(Sort.by("title").ascending()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.repository.Neo4jRepository; 6 | import org.springframework.data.neo4j.repository.query.Query; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query("" 14 | + "MATCH (person:Person)\n" 15 | + "WHERE id(person) = $id\n" 16 | + "WITH person\n" 17 | + "OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie)\n" 18 | + "OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie)\n" 19 | + "OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson)\n" 20 | + "RETURN DISTINCT person,\n" 21 | + "collect(DISTINCT d) AS directed,\n" 22 | + "collect(DISTINCT a) AS actedIn,\n" 23 | + "collect(DISTINCT relatedPerson) AS related\n") 24 | Optional findDetailsById(Long id); 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.springframework.data.neo4j.cypher = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-data-imperative-native/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-imperative/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-data-imperative/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED --add-exports java.base/java.lang=ALL-UNNAMED 2 | -------------------------------------------------------------------------------- /spring-data-imperative/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-data-imperative/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-data-imperative/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/Neo4jConfig.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.neo4j.cypherdsl.core.renderer.Configuration; 4 | import org.neo4j.cypherdsl.core.renderer.Dialect; 5 | import org.springframework.context.annotation.Bean; 6 | 7 | @org.springframework.context.annotation.Configuration(proxyBeanMethods = false) 8 | public class Neo4jConfig { 9 | 10 | @Bean 11 | Configuration cypherDslConfiguration() { 12 | return Configuration.newConfig().withDialect(Dialect.NEO4J_5).build(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/ExtMovieRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | interface ExtMovieRepository { 4 | 5 | MovieDescription updateDescription(String title, String description); 6 | } 7 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/ExtMovieRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.neo4j.core.Neo4jClient; 6 | import org.springframework.data.neo4j.core.Neo4jTemplate; 7 | 8 | final class ExtMovieRepositoryImpl implements ExtMovieRepository { 9 | 10 | private final Neo4jClient client; 11 | 12 | private final Neo4jTemplate template; 13 | 14 | ExtMovieRepositoryImpl(Neo4jClient client, Neo4jTemplate template) { 15 | this.client = client; 16 | this.template = template; 17 | } 18 | 19 | @Override 20 | public MovieDescription updateDescription(String title, String description) { 21 | 22 | var currentVersion = client.query("MATCH (n:Movie WHERE n.title = $title) RETURN n.version").bind(title).to("title") 23 | .fetchAs(Long.class).one().orElse(null); 24 | 25 | var instance = new Movie(currentVersion, title, description, List.of(), List.of()); 26 | return this.template.saveAs(instance, MovieDescription.class); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieDescription.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | public record MovieDescription(String title, String description) { 4 | } 5 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.data.neo4j.repository.Neo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends Neo4jRepository, ExtMovieRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Sort; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | @RestController 14 | @RequestMapping("/api/movies") 15 | public final class MoviesController { 16 | 17 | private final MovieRepository movieRepository; 18 | 19 | MoviesController(MovieRepository movieRepository) { 20 | this.movieRepository = movieRepository; 21 | } 22 | 23 | @GetMapping({ "", "/" }) 24 | public List get() { 25 | return movieRepository.findAll(Sort.by("title").ascending()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.Optional; 4 | 5 | import org.springframework.data.neo4j.repository.Neo4jRepository; 6 | import org.springframework.data.neo4j.repository.query.Query; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | interface PeopleRepository extends Neo4jRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Optional getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/java/org/neo4j/examples/jvm/spring/data/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-data-imperative/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.springframework.data.neo4j.cypher = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-data-imperative/src/test/java/org/neo4j/examples/jvm/spring/data/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-reactive/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-data-reactive/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-data-reactive/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-data-reactive/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.reactive; 2 | 3 | import org.neo4j.driver.Driver; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; 8 | import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; 9 | 10 | @SpringBootApplication 11 | public class Application { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(Application.class, args); 15 | } 16 | 17 | @Bean 18 | ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver, ReactiveDatabaseSelectionProvider databaseSelectionProvider) { 19 | return new ReactiveNeo4jTransactionManager(driver, databaseSelectionProvider); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.reactive.movies; 20 | 21 | import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | interface MovieRepository extends ReactiveNeo4jRepository { 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.reactive.movies; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import org.springframework.data.domain.Sort; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @author Michael J. Simons 13 | */ 14 | @RestController 15 | @RequestMapping("/api/movies") 16 | public final class MoviesController { 17 | 18 | private final MovieRepository movieRepository; 19 | 20 | MoviesController(MovieRepository movieRepository) { 21 | this.movieRepository = movieRepository; 22 | } 23 | 24 | @GetMapping(value = { "", "/" }, produces = MediaType.APPLICATION_JSON_VALUE) 25 | public Flux get() { 26 | return movieRepository.findAll(Sort.by("title").ascending()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.data.reactive.movies; 20 | 21 | import reactor.core.publisher.Mono; 22 | 23 | import org.springframework.http.HttpStatus; 24 | import org.springframework.web.bind.annotation.PostMapping; 25 | import org.springframework.web.bind.annotation.RequestBody; 26 | import org.springframework.web.bind.annotation.RequestMapping; 27 | import org.springframework.web.bind.annotation.ResponseStatus; 28 | import org.springframework.web.bind.annotation.RestController; 29 | 30 | /** 31 | * @author Michael J. Simons 32 | */ 33 | @RestController 34 | @RequestMapping("/api/people") 35 | public class PeopleController { 36 | 37 | private final PeopleRepository peopleRepository; 38 | 39 | public PeopleController(PeopleRepository peopleRepository) { 40 | this.peopleRepository = peopleRepository; 41 | } 42 | 43 | @PostMapping 44 | @ResponseStatus(value = HttpStatus.CREATED) 45 | Mono createNewPerson(@RequestBody Person person) { 46 | 47 | return peopleRepository.save(person); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.reactive.movies; 2 | 3 | import reactor.core.publisher.Mono; 4 | 5 | import java.util.Optional; 6 | 7 | import org.springframework.data.neo4j.repository.Neo4jRepository; 8 | import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; 9 | import org.springframework.data.neo4j.repository.query.Query; 10 | 11 | /** 12 | * @author Michael J. Simons 13 | */ 14 | interface PeopleRepository extends ReactiveNeo4jRepository { 15 | 16 | @Query(""" 17 | MATCH (person:Person {name: $name}) 18 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 19 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 20 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 21 | RETURN DISTINCT person, 22 | collect(DISTINCT d) AS directed, 23 | collect(DISTINCT a) AS actedIn, 24 | collect(DISTINCT relatedPerson) AS related 25 | """) 26 | Mono getDetailsByName(String name); 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/java/org/neo4j/examples/jvm/spring/data/reactive/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.reactive.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-data-reactive/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | logging.level.org.springframework.data.neo4j.cypher = trace 6 | 7 | management.endpoints.web.base-path=/management 8 | management.endpoint.health.show-details=always 9 | management.endpoint.health.probes.enabled=true 10 | -------------------------------------------------------------------------------- /spring-data-reactive/src/test/java/org/neo4j/examples/jvm/spring/data/reactive/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.data.reactive; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-plain-imperative/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-plain-imperative/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED --add-exports java.base/java.lang=ALL-UNNAMED 2 | -------------------------------------------------------------------------------- /spring-plain-imperative/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-plain-imperative/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-plain-imperative/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.imperative; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.plain.imperative.movies; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | /** 26 | * @author Michael J. Simons 27 | */ 28 | public final class Actor { 29 | 30 | private final String name; 31 | 32 | private final List roles; 33 | 34 | public Actor(String name, final List roles) { 35 | this.name = name; 36 | this.roles = new ArrayList<>(roles); 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public List getRoles() { 44 | return Collections.unmodifiableList(roles); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.imperative.movies; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author Michael J. Simons 11 | */ 12 | @RestController 13 | @RequestMapping("/api/movies") 14 | public final class MoviesController { 15 | 16 | private final MovieRepository movieRepository; 17 | 18 | MoviesController(MovieRepository movieRepository) { 19 | this.movieRepository = movieRepository; 20 | } 21 | 22 | @GetMapping({ "", "/" }) 23 | public List get() { 24 | return movieRepository.findAll(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/movies/PeopleController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.plain.imperative.movies; 20 | 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.web.bind.annotation.PostMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.ResponseStatus; 26 | import org.springframework.web.bind.annotation.RestController; 27 | 28 | /** 29 | * @author Michael J. Simons 30 | */ 31 | @RestController 32 | @RequestMapping("/api/people") 33 | public class PeopleController { 34 | 35 | private final PeopleRepository peopleRepository; 36 | 37 | public PeopleController(PeopleRepository peopleRepository) { 38 | this.peopleRepository = peopleRepository; 39 | } 40 | 41 | @PostMapping 42 | @ResponseStatus(value = HttpStatus.CREATED) 43 | Person createNewPerson(@RequestBody Person person) { 44 | 45 | return peopleRepository.save(person); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.plain.imperative.movies; 20 | 21 | import com.fasterxml.jackson.annotation.JsonCreator; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | public final class Person { 27 | 28 | private final Long id; 29 | 30 | private final String name; 31 | 32 | private Integer born; 33 | 34 | Person(Long id, String name, Integer born) { 35 | this.id = id; 36 | this.born = born; 37 | this.name = name; 38 | } 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this(null, name, born); 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public Integer getBorn() { 54 | return born; 55 | } 56 | 57 | public void setBorn(Integer born) { 58 | this.born = born; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/java/org/neo4j/examples/jvm/spring/plain/imperative/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.imperative.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | management.endpoints.web.base-path=/management 6 | management.endpoint.health.show-details=always 7 | management.endpoint.health.probes.enabled=true 8 | -------------------------------------------------------------------------------- /spring-plain-imperative/src/test/java/org/neo4j/examples/jvm/spring/plain/imperative/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.imperative; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-plain-reactive/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-plain-reactive/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED --add-exports java.base/java.lang=ALL-UNNAMED 2 | -------------------------------------------------------------------------------- /spring-plain-reactive/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/spring-plain-reactive/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-plain-reactive/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/java/org/neo4j/examples/jvm/spring/plain/reactive/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.reactive; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/java/org/neo4j/examples/jvm/spring/plain/reactive/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.plain.reactive.movies; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | /** 26 | * @author Michael J. Simons 27 | */ 28 | public final class Actor { 29 | 30 | private final String name; 31 | 32 | private final List roles; 33 | 34 | public Actor(String name, final List roles) { 35 | this.name = name; 36 | this.roles = new ArrayList<>(roles); 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public List getRoles() { 44 | return Collections.unmodifiableList(roles); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/java/org/neo4j/examples/jvm/spring/plain/reactive/movies/MoviesController.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.reactive.movies; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import org.springframework.http.MediaType; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author Michael J. Simons 12 | */ 13 | @RestController 14 | @RequestMapping("/api/movies") 15 | public final class MoviesController { 16 | 17 | private final MovieRepository movieRepository; 18 | 19 | MoviesController(MovieRepository movieRepository) { 20 | this.movieRepository = movieRepository; 21 | } 22 | 23 | @GetMapping(value = { "", "/" }, produces = MediaType.APPLICATION_JSON_VALUE) 24 | public Flux get() { 25 | return movieRepository.findAll(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/java/org/neo4j/examples/jvm/spring/plain/reactive/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.spring.plain.reactive.movies; 20 | 21 | import com.fasterxml.jackson.annotation.JsonCreator; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | public final class Person { 27 | 28 | private final Long id; 29 | 30 | private final String name; 31 | 32 | private Integer born; 33 | 34 | Person(Long id, String name, Integer born) { 35 | this.id = id; 36 | this.born = born; 37 | this.name = name; 38 | } 39 | 40 | @JsonCreator 41 | public Person(String name, Integer born) { 42 | this(null, name, born); 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public Integer getBorn() { 54 | return born; 55 | } 56 | 57 | public void setBorn(Integer born) { 58 | this.born = born; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/java/org/neo4j/examples/jvm/spring/plain/reactive/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.reactive.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | management.endpoints.web.base-path=/management 6 | management.endpoint.health.show-details=always 7 | management.endpoint.health.probes.enabled=true 8 | -------------------------------------------------------------------------------- /spring-plain-reactive/src/test/java/org/neo4j/examples/jvm/spring/plain/reactive/ApplicationIT.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.spring.plain.reactive; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ApplicationIT { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /tck/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/tck/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /tck/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.tck; 2 | 3 | import picocli.CommandLine; 4 | 5 | import org.neo4j.examples.jvm.tck.cli.Cli; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.ExitCodeGenerator; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | 11 | /** 12 | * @author Michael J. Simons 13 | */ 14 | @SpringBootApplication 15 | public class Application implements CommandLineRunner, ExitCodeGenerator { 16 | 17 | public static void main(String[] args) { 18 | System.exit(SpringApplication.exit(SpringApplication.run(Application.class, args))); 19 | } 20 | 21 | private final CommandLine.IFactory factory; 22 | 23 | private int exitCode; 24 | 25 | Application(CommandLine.IFactory factory) { 26 | this.factory = factory; 27 | } 28 | 29 | @Override 30 | public void run(String... args) { 31 | this.exitCode = new CommandLine(Cli.class, factory) 32 | .setUnmatchedArgumentsAllowed(true) 33 | .execute(args); 34 | } 35 | 36 | @Override 37 | public int getExitCode() { 38 | return this.exitCode; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/cli/Cli.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.tck.cli; 2 | 3 | import picocli.CommandLine.Command; 4 | import picocli.CommandLine.Model.CommandSpec; 5 | import picocli.CommandLine.ParameterException; 6 | import picocli.CommandLine.Spec; 7 | 8 | import java.util.logging.Logger; 9 | 10 | @Command( 11 | name = "tck", 12 | mixinStandardHelpOptions = true, 13 | description = "Provides a set of helpful commands against a Neo4j database", 14 | subcommands = { LoadMovies.class, VerifyConnection.class } 15 | ) 16 | public final class Cli implements Runnable { 17 | 18 | static final Logger LOGGER = Logger.getLogger(Cli.class.getName()); 19 | 20 | @Spec 21 | private CommandSpec commandSpec; 22 | 23 | @Override 24 | public void run() { 25 | throw new ParameterException(commandSpec.commandLine(), "Missing required subcommand"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/cli/LoadMovies.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.tck.cli; 2 | 3 | import ac.simons.neo4j.migrations.core.Migrations; 4 | import picocli.CommandLine; 5 | import picocli.CommandLine.Command; 6 | 7 | import java.util.concurrent.Callable; 8 | 9 | /** 10 | * @author Michael J. Simons 11 | */ 12 | @Command(name = "loadMovies", description = "Clears the database and loads the movie graph.") 13 | final class LoadMovies implements Callable { 14 | 15 | 16 | private final Migrations migrations; 17 | 18 | LoadMovies(Migrations movieService) { 19 | this.migrations = movieService; 20 | } 21 | 22 | @Override 23 | public Integer call() { 24 | 25 | try { 26 | this.migrations.apply().ifPresent(v -> Cli.LOGGER.info("Database now at " + v.getValue())); 27 | return CommandLine.ExitCode.OK; 28 | } catch (Exception e) { 29 | Cli.LOGGER.severe("Could not apply migrations: " + e.getMessage()); 30 | return CommandLine.ExitCode.SOFTWARE; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/cli/VerifyConnection.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.tck.cli; 2 | 3 | import picocli.CommandLine; 4 | import picocli.CommandLine.Command; 5 | import picocli.CommandLine.Option; 6 | 7 | import java.time.Duration; 8 | import java.time.Instant; 9 | import java.util.concurrent.Callable; 10 | import java.util.logging.Level; 11 | import java.util.logging.Logger; 12 | 13 | import org.neo4j.driver.Driver; 14 | import org.neo4j.driver.exceptions.ServiceUnavailableException; 15 | 16 | /** 17 | * @author Michael J. Simons 18 | */ 19 | @Command(name = "verifyConnection", description = "Tries to open up a connection to the database.") 20 | final class VerifyConnection implements Callable { 21 | 22 | @Option( 23 | names = { "-t", "--timeout" }, 24 | description = "The timeout for the verification.", 25 | required = true, 26 | defaultValue = "PT120S" 27 | ) 28 | private final Duration timeout = Duration.ofSeconds(120); 29 | 30 | private final Driver driver; 31 | 32 | VerifyConnection(Driver driver) { 33 | this.driver = driver; 34 | } 35 | 36 | @Override 37 | public Integer call() throws Exception { 38 | 39 | var waitingStarted = Instant.now(); 40 | while (Duration.between(waitingStarted, Instant.now()).compareTo(timeout) < 0) { 41 | try { 42 | driver.verifyConnectivity(); 43 | return CommandLine.ExitCode.OK; 44 | } catch (ServiceUnavailableException e) { 45 | Cli.LOGGER.log(Level.INFO, "Waiting for Neo4j to be reachable."); 46 | Thread.sleep(500); 47 | } 48 | } 49 | 50 | return CommandLine.ExitCode.SOFTWARE; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.tck.movies; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | public record Actor( 27 | 28 | String name, 29 | 30 | List roles 31 | ) { 32 | } 33 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/movies/Movie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.tck.movies; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | public record Movie( 27 | 28 | String title, 29 | 30 | String description, 31 | 32 | List actors, 33 | 34 | List directors, 35 | 36 | Integer released 37 | ) { 38 | } 39 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/movies/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.tck.movies; 20 | 21 | import com.fasterxml.jackson.annotation.JsonInclude; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 27 | public record Person( 28 | Long id, 29 | 30 | String name, 31 | 32 | Integer born 33 | ) { 34 | 35 | public Person(String name, Integer born) { 36 | this(null, name, born); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tck/src/main/java/org/neo4j/examples/jvm/tck/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.tck.movies; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Michael J. Simons 7 | */ 8 | public record PersonDetails( 9 | 10 | String name, 11 | 12 | Integer born, 13 | 14 | List actedIn, 15 | 16 | List directed, 17 | 18 | List related 19 | ) { 20 | } 21 | -------------------------------------------------------------------------------- /tck/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=bolt://localhost:7687 2 | spring.neo4j.authentication.username=neo4j 3 | spring.neo4j.authentication.password=secret 4 | 5 | spring.main.banner-mode=off 6 | 7 | spring.jackson.deserialization.fail-on-ignored-properties=true 8 | spring.jackson.deserialization.fail-on-unknown-properties=true 9 | 10 | spring.main.web-application-type=none 11 | 12 | org.neo4j.migrations.locations-to-scan=neo4j/migrations,neo4j/example-data 13 | org.neo4j.migrations.enabled=false 14 | -------------------------------------------------------------------------------- /tck/src/main/resources/neo4j/example-data/beforeMigrate__clean_database.cypher: -------------------------------------------------------------------------------- 1 | MATCH (n:Movie) DETACH DELETE n; 2 | -------------------------------------------------------------------------------- /tck/src/main/resources/neo4j/migrations/V0001__Remove_old_indexes.cypher: -------------------------------------------------------------------------------- 1 | DROP CONSTRAINT title_unique IF EXISTS; 2 | -------------------------------------------------------------------------------- /tck/src/main/resources/neo4j/migrations/V0002__Create_movie_title_index.cypher: -------------------------------------------------------------------------------- 1 | CREATE INDEX movie_title_index IF NOT EXISTS FOR (n:Movie) ON (n.title); 2 | -------------------------------------------------------------------------------- /tck/src/main/resources/neo4j/migrations/V0003__Create_person_name_index.cypher: -------------------------------------------------------------------------------- 1 | CREATE INDEX person_name_index IF NOT EXISTS FOR (n:Person) ON (n.name); 2 | -------------------------------------------------------------------------------- /tck/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-simons/neo4j-from-the-jvm-ecosystem/c4ae4fc4d57d1917b938a884085c6eb7b95f1ff0/vertx-spring-data-reactive/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /vertx-spring-data-reactive/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/Application.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.vertx.sdn; 2 | 3 | import io.vertx.core.logging.SLF4JLogDelegateFactory; 4 | 5 | import org.neo4j.driver.Driver; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; 10 | import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; 11 | 12 | @SpringBootApplication 13 | public class Application { 14 | 15 | public static void main(String[] args) { 16 | 17 | String logFactory = System.getProperty("org.vertx.logger-delegate-factory-class-name"); 18 | if (logFactory == null) { 19 | System.setProperty("org.vertx.logger-delegate-factory-class-name", SLF4JLogDelegateFactory.class.getName()); 20 | } 21 | 22 | SpringApplication.run(Application.class, args); 23 | } 24 | 25 | @Bean 26 | ReactiveNeo4jTransactionManager reactiveTransactionManager( 27 | Driver driver, ReactiveDatabaseSelectionProvider databaseSelectionProvider) { 28 | return new ReactiveNeo4jTransactionManager(driver, databaseSelectionProvider); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/VertxRunner.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.vertx.sdn; 2 | 3 | import io.vertx.core.Vertx; 4 | 5 | import org.neo4j.driver.Driver; 6 | import org.neo4j.examples.jvm.vertx.sdn.movies.MovieRepository; 7 | import org.neo4j.examples.jvm.vertx.sdn.movies.PeopleRepository; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.boot.CommandLineRunner; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * This kicks off VertX. 14 | */ 15 | @Component 16 | public final class VertxRunner implements CommandLineRunner { 17 | 18 | private final int port; 19 | 20 | private final Driver driver; 21 | private final MovieRepository movieService; 22 | private final PeopleRepository peopleRepository; 23 | 24 | public VertxRunner(@Value("${server.port:8080}") int port, 25 | Driver driver, MovieRepository movieService, 26 | PeopleRepository peopleRepository 27 | ) { 28 | this.port = port; 29 | this.driver = driver; 30 | 31 | this.movieService = movieService; 32 | this.peopleRepository = peopleRepository; 33 | } 34 | 35 | @Override 36 | public void run(String... args) { 37 | 38 | final Vertx vertx = Vertx.vertx(); 39 | vertx.deployVerticle(new APIVerticle(port, driver, movieService, peopleRepository)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/movies/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.vertx.sdn.movies; 20 | 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 25 | import org.springframework.data.neo4j.core.schema.TargetNode; 26 | 27 | import com.fasterxml.jackson.annotation.JsonIgnore; 28 | import com.fasterxml.jackson.annotation.JsonProperty; 29 | 30 | /** 31 | * @author Michael J. Simons 32 | */ 33 | @RelationshipProperties 34 | public final class Actor { 35 | 36 | @TargetNode 37 | @JsonIgnore 38 | private final Person person; 39 | 40 | private final List roles; 41 | 42 | public Actor(Person person, List roles) { 43 | this.person = person; 44 | this.roles = roles; 45 | } 46 | 47 | public Person getPerson() { 48 | return person; 49 | } 50 | 51 | @JsonProperty 52 | public String getName() { 53 | return person.getName(); 54 | } 55 | 56 | public List getRoles() { 57 | return Collections.unmodifiableList(roles); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/movies/MovieRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2020 "Neo4j," 3 | * Neo4j Sweden AB [http://neo4j.com] 4 | * 5 | * This file is part of Neo4j. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.neo4j.examples.jvm.vertx.sdn.movies; 20 | 21 | import org.springframework.data.repository.reactive.RxJava2SortingRepository; 22 | 23 | /** 24 | * @author Michael J. Simons 25 | */ 26 | public interface MovieRepository extends RxJava2SortingRepository { 27 | } 28 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/movies/PeopleRepository.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.vertx.sdn.movies; 2 | 3 | import io.reactivex.Maybe; 4 | 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.reactive.RxJava2SortingRepository; 7 | 8 | /** 9 | * @author Michael J. Simons 10 | */ 11 | public interface PeopleRepository extends RxJava2SortingRepository { 12 | 13 | @Query(""" 14 | MATCH (person:Person {name: $name}) 15 | OPTIONAL MATCH (person)-[:DIRECTED]->(d:Movie) 16 | OPTIONAL MATCH (person)<-[r:ACTED_IN]->(a:Movie) 17 | OPTIONAL MATCH (person)-->(movies)<-[relatedRole:ACTED_IN]-(relatedPerson) 18 | RETURN DISTINCT person, 19 | collect(DISTINCT d) AS directed, 20 | collect(DISTINCT a) AS actedIn, 21 | collect(DISTINCT relatedPerson) AS related 22 | """) 23 | Maybe getDetailsByName(String name); 24 | } 25 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/java/org/neo4j/examples/jvm/vertx/sdn/movies/PersonDetails.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.examples.jvm.vertx.sdn.movies; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * This is a DTO based projection, containing a couple of additional details, 9 | * like the list of movies a person acted in, the movies they direct and which other 10 | * people they acted with 11 | * 12 | * @author Michael J. Simons 13 | */ 14 | public final class PersonDetails { 15 | 16 | private final String name; 17 | 18 | private final Integer born; 19 | 20 | private final List actedIn; 21 | 22 | private final List directed; 23 | 24 | private final List related; 25 | 26 | public PersonDetails(String name, Integer born, List actedIn, 27 | List directed, List related) { 28 | this.name = name; 29 | this.born = born; 30 | this.actedIn = new ArrayList<>(actedIn); 31 | this.directed = new ArrayList<>(directed); 32 | this.related = new ArrayList<>(related); 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public Integer getBorn() { 40 | return born; 41 | } 42 | 43 | public List getActedIn() { 44 | return Collections.unmodifiableList(actedIn); 45 | } 46 | 47 | public List getDirected() { 48 | return Collections.unmodifiableList(directed); 49 | } 50 | 51 | public List getRelated() { 52 | return Collections.unmodifiableList(related); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vertx-spring-data-reactive/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # We don't want Springs web server 2 | spring.main.web-application-type=none 3 | 4 | logging.level.io.vertx=trace 5 | logging.level.org.springframework.data.neo4j.cypher=debug 6 | 7 | spring.neo4j.authentication.username=neo4j 8 | spring.neo4j.authentication.password=secret 9 | 10 | server.port=8080 11 | --------------------------------------------------------------------------------