From 1e84418f92f41e4a233e502208e66a12f48a1b8e Mon Sep 17 00:00:00 2001 From: Andrey Date: Sat, 2 Jun 2012 22:02:55 +0400 Subject: [PATCH] Removed hello-worlds-aspects project, implemented 2 profiles for hello-worlds: aspects and plain. The code doesn't work as expected. Commiting just for back-up --- pom.xml | 1 - .../hello-worlds-aspects/.gitignore | 11 - .../hello-worlds-aspects/README.md | 14 - .../hello-worlds-aspects/build.gradle | 27 -- .../hello-worlds-aspects/build.xml | 75 --- .../hello-worlds-aspects/pom.xml | 210 -------- .../settings/install-ivy.xml | 29 -- .../hello-worlds-aspects/settings/ivy.xml | 14 - .../settings/ivysettings.xml | 23 - .../hello-worlds-aspects/settings/path.xml | 30 -- .../data/neo4j/examples/hellograph/App.java | 30 -- .../examples/hellograph/GalaxyMapper.java | 27 -- .../examples/hellograph/GalaxyService.java | 64 --- .../hellograph/MyWorldRepository.java | 12 - .../hellograph/RelationshipTypes.java | 5 - .../data/neo4j/examples/hellograph/World.java | 49 -- .../neo4j/examples/hellograph/WorldDto.java | 30 -- .../examples/hellograph/WorldRepository.java | 10 - .../hellograph/WorldRepositoryImpl.java | 55 --- .../src/main/resources/log4j.properties | 7 - .../hellograph/GalaxyServiceTest.java | 58 --- .../hello-worlds/pom.xml | 448 +++++++++++------- .../data/neo4j/examples/hellograph/App.java | 10 +- .../examples/hellograph/GalaxyService.java | 5 +- .../hellograph/MyWorldRepository.java | 12 - .../data/neo4j/examples/hellograph/World.java | 10 +- .../examples/hellograph/WorldRepository.java | 2 +- .../hellograph/WorldRepositoryImpl.java | 56 --- .../spring/aspects}/helloWorldContext.xml | 14 +- .../resources/spring/helloWorldContext.xml | 19 - .../spring/plain/helloWorldContext.xml | 25 + .../hellograph/GalaxyServiceTest.java | 3 +- 32 files changed, 338 insertions(+), 1047 deletions(-) delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/.gitignore delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/README.md delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/build.gradle delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/build.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/pom.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyMapper.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/RelationshipTypes.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldDto.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties delete mode 100644 spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java delete mode 100644 spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java delete mode 100644 spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java rename spring-data-neo4j-examples/{hello-worlds-aspects/src/main/resources/spring => hello-worlds/src/main/resources/spring/aspects}/helloWorldContext.xml (51%) delete mode 100644 spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml create mode 100644 spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml diff --git a/pom.xml b/pom.xml index f5d07710e..1ade39698 100644 --- a/pom.xml +++ b/pom.xml @@ -156,7 +156,6 @@ examples spring-data-neo4j-examples/hello-worlds - spring-data-neo4j-examples/hello-worlds-aspects spring-data-neo4j-examples/imdb spring-data-neo4j-examples/cineasts spring-data-neo4j-examples/cineasts-aspects diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore b/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore deleted file mode 100644 index f092f6270..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -lib -.ivy -.gradle -target -*.ipr -*.iml -*.iws -.classpath -.project -.settings - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/README.md b/spring-data-neo4j-examples/hello-worlds-aspects/README.md deleted file mode 100644 index 70d44f759..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/README.md +++ /dev/null @@ -1,14 +0,0 @@ -Hello Worlds -============ - -A simple Spring Data Neo4j example with just enough code to -do something that works. - -This version of the project takes advantage of the niceties -provided by spring-data-neo4j-aspects, which enhances the -Plain Old Java Objects into Deluxe Aspect Java Objects. - -Build and Run -------------- - -`mvn clean package exec:java` diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle b/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle deleted file mode 100644 index 7ffdbf9b7..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -sourceCompatibility = 1.6 -targetCompatibility = 1.6 - -apply plugin: 'idea' -apply plugin: 'eclipse' - - -springVersion = "3.0.7.RELEASE" -springDataNeo4jVersion = "2.0.0.RELEASE" -aspectjVersion = "1.6.12" - -apply from:'https://github.com/SpringSource/spring-data-neo4j/raw/master/build/gradle/springdataneo4j.gradle' - -configurations { - runtime - testCompile -} -repositories { - mavenCentral() - mavenLocal() - mavenRepo urls: "http://maven.springframework.org/release" -} - - -dependencies{ - testCompile group:"junit", name: "junit", version: "4.8" -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/build.xml b/spring-data-neo4j-examples/hello-worlds-aspects/build.xml deleted file mode 100644 index 60a0d7f3d..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/build.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml b/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml deleted file mode 100644 index a4808f42a..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/pom.xml +++ /dev/null @@ -1,210 +0,0 @@ - - 4.0.0 - - org.springframework.data.examples - spring-data-neo4j-hello-worlds-aspects - 2.1.0.BUILD-SNAPSHOT - jar - - Spring Data Neo4j hello-worlds Aspects - - - UTF-8 - 3.0.7.RELEASE - 1.6.12 - 1.6.1 - ${project.version} - - - - - spring-maven-release - Spring Maven Release Repository - http://maven.springframework.org/release - - - spring-maven-snapshot - Spring Maven Snapshot Repository - - true - - http://maven.springframework.org/snapshot - - - spring-maven-milestone - Spring Maven Milestone Repository - http://maven.springframework.org/milestone - - - neo4j-release-repository - Neo4j Maven 2 release repository - http://m2.neo4j.org/releases - - true - - - false - - - - neo4j-snapshot-repository - Neo4j Maven 2 snapshot repository - http://m2.neo4j.org/snapshots - - true - - - false - - - - - - - spring-maven-release - Spring Maven Release Repository - http://maven.springframework.org/release - - - spring-maven-milestone - Spring Maven Milestone Repository - http://maven.springframework.org/milestone - - - - - - junit - junit - 4.8.1 - test - - - org.springframework - spring-test - ${spring.version} - test - - - commons-logging - commons-logging - - - - - org.springframework.data - spring-data-neo4j-aspects - ${spring-data-neo4j.version} - - - cglib - cglib-nodep - 2.2 - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.1 - - 1.6 - 1.6 - - - - - - org.codehaus.mojo - aspectj-maven-plugin - 1.2 - - true - - - org.springframework - spring-aspects - - - org.springframework.data - spring-data-neo4j-aspects - - - 1.6 - 1.6 - - - - - compile - test-compile - - - - - - org.aspectj - aspectjrt - ${aspectj.version} - - - org.aspectj - aspectjtools - ${aspectj.version} - - - - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.8 - - - 1.5 - - org.eclipse.ajdt.ui.ajnature - org.eclipse.jdt.core.javanature - org.springframework.ide.eclipse.core.springnature - - - - - - - org.apache.maven.plugins - maven-idea-plugin - 2.2 - - true - true - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2 - - - - exec - - - - - org.springframework.data.neo4j.examples.hellograph.App - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml deleted file mode 100644 index 314d20d9a..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/settings/install-ivy.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml deleted file mode 100644 index 5fb5f95e1..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivy.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml deleted file mode 100644 index 704bb0fbc..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/settings/ivysettings.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml b/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml deleted file mode 100644 index 3d49c706b..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/settings/path.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java deleted file mode 100644 index 11fe901cb..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class App { - public static void main(String[] args) { - ConfigurableApplicationContext applicationContext = - new ClassPathXmlApplicationContext("/spring/helloWorldContext.xml"); - - MyWorldRepository galaxy = applicationContext.getBean(WorldRepositoryImpl.class); - galaxy.makeSureGalaxyIsNotEmpty(); - - System.out.println("Trying to find the Earth by its name:"); - World earth = galaxy.findWorldNamed("Earth"); - System.out.printf("Found Earth: %s\n", earth); - - System.out.println("Retrieveing the list of worlds that can be reached from the Earth:"); - for(World world : earth.getReachableWorlds()) { - System.out.printf("Can travel between %s and %s\n", earth, world); - } - - System.out.println("Here's the list of all worlds in the galaxy:"); - for(World world : galaxy.findAllWorlds()) { - System.out.printf("There's a world: %s\n", world); - } - - applicationContext.close(); - } -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyMapper.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyMapper.java deleted file mode 100644 index 97cdb12ce..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.stereotype.Service; - -@Service -public class GalaxyMapper { - public WorldDto worldDtoFromWorld(World world) { - if(world == null) { - return null; - } - - return new WorldDto(world.getId(), world.getName(), world.getMoons()); - } - - public List worldDtosFromWorlds(Iterable worlds) { - List worldDtos = new ArrayList(); - for(World world : worlds) { - WorldDto worldDto = worldDtoFromWorld(world); - worldDtos.add(worldDto); - } - - return worldDtos; - } -} \ No newline at end of file diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java deleted file mode 100644 index c443d89aa..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -public class GalaxyService { - @Autowired - private WorldRepository worldRepository; - - @Autowired - private GalaxyMapper mapper; - - @Transactional - public void makeSureGalaxyIsNotEmpty() { - // Solar worlds - resolveWorld("Mercury", 0); - resolveWorld("Venus", 0); - - World earth = resolveWorld("Earth", 1); - World mars = resolveWorld("Mars", 2); - mars.addRocketRouteTo(earth); - - resolveWorld("Jupiter", 63); - resolveWorld("Saturn", 62); - resolveWorld("Uranus", 27); - resolveWorld("Neptune", 13); - - // Norse worlds - resolveWorld("Alfheimr", 0); - resolveWorld("Midgard", 1); - resolveWorld("Muspellheim", 2); - resolveWorld("Asgard", 63); - resolveWorld("Hel", 62); - } - - private World resolveWorld(String name, int moons) { - World createdWorld = worldRepository.findByPropertyValue("name", name); - if (createdWorld == null) { - createdWorld = new World(name, moons); - createdWorld = worldRepository.save(createdWorld); - } - return createdWorld; - } - - public WorldDto findWorldNamed(String name) { - World world = worldRepository.findByPropertyValue("name", name); - return mapper.worldDtoFromWorld(world); - } - - public List findReachableWorlds(Long worldId) { - World world = worldRepository.findOne(worldId); - return mapper.worldDtosFromWorlds(world.getReachableWorlds()); - } - - public List findAllWorlds() { - Iterable worlds = worldRepository.findAll(); - return mapper.worldDtosFromWorlds(worlds); - } -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java deleted file mode 100644 index 1c17e10c1..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.transaction.annotation.Transactional; - -public interface MyWorldRepository { - @Transactional - void makeSureGalaxyIsNotEmpty(); - - World findWorldNamed(String name); - - Iterable findAllWorlds(); -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/RelationshipTypes.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/RelationshipTypes.java deleted file mode 100644 index 0477649d4..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/RelationshipTypes.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -public abstract class RelationshipTypes { - public static final String REACHABLE_BY_ROCKET = "REACHABLE_BY_ROCKET"; -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java deleted file mode 100644 index 0c228907f..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - - -import org.neo4j.graphdb.Direction; -import org.springframework.data.neo4j.annotation.Indexed; -import org.springframework.data.neo4j.annotation.NodeEntity; -import org.springframework.data.neo4j.annotation.RelatedTo; - -import java.util.Set; - -@NodeEntity -public class World { - @Indexed - private String name; - - private int moons; - - @RelatedTo(type = RelationshipTypes.REACHABLE_BY_ROCKET, elementClass = World.class, direction = Direction.BOTH) - private Set reachableByRocket; - - public World(String name, int moons) { - this.name = name; - this.moons = moons; - } - - public World() { - } - - public String getName() { - return name; - } - - public int getMoons() { - return moons; - } - - @Override - public String toString() { - return String.format("World{name='%s', moons=%d}", name, moons); - } - - public void addRocketRouteTo(World otherWorld) { - relateTo(otherWorld, RelationshipTypes.REACHABLE_BY_ROCKET); - } - - public Iterable getReachableWorlds() { - return reachableByRocket; - } -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldDto.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldDto.java deleted file mode 100644 index 9860fe2b8..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -public class WorldDto { - private final Long id; - private final String name; - private final int moons; - - public WorldDto(Long id, String name, int moons) { - this.id = id; - this.name = name; - this.moons = moons; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public int getMoons() { - return moons; - } - - @Override - public String toString() { - return String.format("WorldDto{id=%d, name='%s', moons=%d}", id, name, moons); - } -} \ No newline at end of file diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java deleted file mode 100644 index b693f5c8a..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.data.neo4j.repository.GraphRepository; - -/** - * @author mh - * @since 01.04.11 - */ -public interface WorldRepository extends MyWorldRepository, GraphRepository { -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java deleted file mode 100644 index 5ff279f6c..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -/** - * Spring Data Neo4j backed application context for Worlds. - */ -public class WorldRepositoryImpl implements MyWorldRepository { - - @Autowired - private WorldRepository worldRepository; - - @Override - @Transactional - public void makeSureGalaxyIsNotEmpty() { - // Solar worlds - resolveWorld("Mercury", 0); - resolveWorld("Venus", 0); - - World earth = resolveWorld("Earth", 1); - World mars = resolveWorld("Mars", 2); - mars.addRocketRouteTo(earth); - - resolveWorld("Jupiter", 63); - resolveWorld("Saturn", 62); - resolveWorld("Uranus", 27); - resolveWorld("Neptune", 13); - - // Norse worlds - resolveWorld("Alfheimr", 0); - resolveWorld("Midgard", 1); - resolveWorld("Muspellheim", 2); - resolveWorld("Asgard", 63); - resolveWorld("Hel", 62); - } - - private World resolveWorld(String name, int moons) { - World createdWorld = findWorldNamed(name); - if (createdWorld == null) { - createdWorld = new World(name, moons).persist(); - } - return createdWorld; - } - - @Override - public World findWorldNamed(String name) { - return worldRepository.findByPropertyValue("name", name); - } - - @Override - public Iterable findAllWorlds() { - return worldRepository.findAll(); - } -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties b/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties deleted file mode 100644 index beb86feab..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/log4j.properties +++ /dev/null @@ -1,7 +0,0 @@ -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -# Print the date in ISO 8601 format -log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n - -log4j.rootLogger=ERROR, stdout diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java b/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java deleted file mode 100644 index a8b9ed43b..000000000 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.support.Neo4jTemplate; -import org.springframework.data.neo4j.support.node.Neo4jHelper; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@ContextConfiguration(locations = "classpath:/spring/helloWorldContext.xml") -@RunWith(SpringJUnit4ClassRunner.class) -public class GalaxyServiceTest { - - @Autowired - private GalaxyService galaxyService; - - @Autowired - private Neo4jTemplate template; - - @Before - public void cleanUpGraph() { - Neo4jHelper.cleanDb(template); - } - - @Test - public void galaxyShouldBeEmptyUntilExplicitlyPopulated() { - assertTrue(galaxyService.findAllWorlds().isEmpty()); - } - - @Test - public void populatedGalaxyShouldHaveEarth() { - galaxyService.makeSureGalaxyIsNotEmpty(); - WorldDto earth = galaxyService.findWorldNamed("Earth"); - assertNotNull(earth); - assertEquals("Earth", earth.getName()); - } - - @Test - public void earthShouldHaveOnlyOneReachableWorld() { - galaxyService.makeSureGalaxyIsNotEmpty(); - WorldDto earth = galaxyService.findWorldNamed("Earth"); - List reachableWorlds = galaxyService.findReachableWorlds(earth.getId()); - assertEquals(1, reachableWorlds.size()); - } - - @Test - public void populatedGalaxyShouldNotHaveKrypton() { - galaxyService.makeSureGalaxyIsNotEmpty(); - WorldDto planetPopsicle = galaxyService.findWorldNamed("Krypton"); - assertNull(planetPopsicle); - } -} diff --git a/spring-data-neo4j-examples/hello-worlds/pom.xml b/spring-data-neo4j-examples/hello-worlds/pom.xml index 2b7d289f0..ec02a14e1 100644 --- a/spring-data-neo4j-examples/hello-worlds/pom.xml +++ b/spring-data-neo4j-examples/hello-worlds/pom.xml @@ -1,178 +1,300 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.springframework.data.examples - spring-data-neo4j-hello-worlds - 2.1.0.BUILD-SNAPSHOT - jar + org.springframework.data.examples + spring-data-neo4j-hello-worlds + 2.1.0.BUILD-SNAPSHOT + jar - Spring Data Neo4j hello-worlds + Spring Data Neo4j hello-worlds - - UTF-8 - 3.0.7.RELEASE - 1.6.12 - 1.6.1 - ${project.version} - + + UTF-8 + 3.0.7.RELEASE + 1.6.12 + 1.6.1 + ${project.version} + - - - spring-maven-release - Spring Maven Release Repository - http://maven.springframework.org/release - - - spring-maven-snapshot - Spring Maven Snapshot Repository - - true - - http://maven.springframework.org/snapshot - - - spring-maven-milestone - Spring Maven Milestone Repository - http://maven.springframework.org/milestone - - - neo4j-release-repository - Neo4j Maven 2 release repository - http://m2.neo4j.org/releases - - true - - - false - - - - neo4j-snapshot-repository - Neo4j Maven 2 snapshot repository - http://m2.neo4j.org/snapshots - - true - - - false - - - + + + spring-maven-release + Spring Maven Release Repository + http://maven.springframework.org/release + + + spring-maven-snapshot + Spring Maven Snapshot Repository + + true + + http://maven.springframework.org/snapshot + + + spring-maven-milestone + Spring Maven Milestone Repository + http://maven.springframework.org/milestone + + + neo4j-release-repository + Neo4j Maven 2 release repository + http://m2.neo4j.org/releases + + true + + + false + + + + neo4j-snapshot-repository + Neo4j Maven 2 snapshot repository + http://m2.neo4j.org/snapshots + + true + + + false + + + - - - spring-maven-release - Spring Maven Release Repository - http://maven.springframework.org/release - - - spring-maven-milestone - Spring Maven Milestone Repository - http://maven.springframework.org/milestone - - + + + spring-maven-release + Spring Maven Release Repository + http://maven.springframework.org/release + + + spring-maven-milestone + Spring Maven Milestone Repository + http://maven.springframework.org/milestone + + - - - junit - junit - 4.8.1 - test - - - org.springframework - spring-test - ${spring.version} - test - - - commons-logging - commons-logging - - - - - org.springframework.data - spring-data-neo4j - ${spring-data-neo4j.version} - - - cglib - cglib-nodep - 2.2 - - + + + junit + junit + 4.8.1 + test + + + org.springframework + spring-test + ${spring.version} + test + + + commons-logging + commons-logging + + + + + cglib + cglib-nodep + 2.2 + + - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.1 - - 1.6 - 1.6 - - + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.1 + + 1.6 + 1.6 + + - - - org.apache.maven.plugins - maven-idea-plugin - 2.2 - - true - true - - + + + org.apache.maven.plugins + maven-idea-plugin + 2.2 + + true + true + + - - - org.codehaus.mojo - exec-maven-plugin - 1.2 - - - - exec - - - - - org.springframework.data.neo4j.examples.hellograph.App - - + + + org.codehaus.mojo + exec-maven-plugin + 1.2 + + + + exec + + + + + org.springframework.data.neo4j.examples.hellograph.App + + - - maven-assembly-plugin - - hello-worlds-${project.version} - false - false - - - org.springframework.data.neo4j.examples.hellograph.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - + + maven-assembly-plugin + + hello-worlds-${project.version} + false + false + + + org.springframework.data.neo4j.examples.hellograph.App + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + maven-resources-plugin + + + initialize + + resources + + + + - - + + + + + plain + + + org.springframework.data + spring-data-neo4j + ${spring-data-neo4j.version} + + + + + + + ${project.basedir}/src/main/resources/spring/plain + ${project.build.directory}/classes/spring + true + + helloWorldContext.xml + + + + + + + aspects + + true + + + + + org.springframework.data + spring-data-neo4j-aspects + ${spring-data-neo4j.version} + + + + + + + + org.codehaus.mojo + aspectj-maven-plugin + 1.2 + + true + + + org.springframework + spring-aspects + + + org.springframework.data + spring-data-neo4j-aspects + + + 1.6 + 1.6 + + + + + compile + test-compile + + + + + + org.aspectj + aspectjrt + ${aspectj.version} + + + org.aspectj + aspectjtools + ${aspectj.version} + + + + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.8 + + + 1.5 + + org.eclipse.ajdt.ui.ajnature + org.eclipse.jdt.core.javanature + org.springframework.ide.eclipse.core.springnature + + + + + + + ${project.basedir}/src/main/resources/spring/aspects + ${project.build.directory}/classes/spring + true + + helloWorldContext.xml + + + + + + diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java index 11fe901cb..25e8b1b9f 100644 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java +++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/App.java @@ -8,20 +8,20 @@ public class App { ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("/spring/helloWorldContext.xml"); - MyWorldRepository galaxy = applicationContext.getBean(WorldRepositoryImpl.class); - galaxy.makeSureGalaxyIsNotEmpty(); + GalaxyService galaxyService = applicationContext.getBean(GalaxyService.class); + galaxyService.makeSureGalaxyIsNotEmpty(); System.out.println("Trying to find the Earth by its name:"); - World earth = galaxy.findWorldNamed("Earth"); + WorldDto earth = galaxyService.findWorldNamed("Earth"); System.out.printf("Found Earth: %s\n", earth); System.out.println("Retrieveing the list of worlds that can be reached from the Earth:"); - for(World world : earth.getReachableWorlds()) { + for(WorldDto world : galaxyService.findReachableWorlds(earth.getId())) { System.out.printf("Can travel between %s and %s\n", earth, world); } System.out.println("Here's the list of all worlds in the galaxy:"); - for(World world : galaxy.findAllWorlds()) { + for(WorldDto world : galaxyService.findAllWorlds()) { System.out.printf("There's a world: %s\n", world); } diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java index a7fa425b7..e3a2967c2 100644 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java +++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/GalaxyService.java @@ -1,6 +1,5 @@ package org.springframework.data.neo4j.examples.hellograph; - import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +24,7 @@ public class GalaxyService { World mars = resolveWorld("Mars", 2); mars.addRocketRouteTo(earth); worldRepository.save(mars); + /*worldRepository.save(earth);*/ resolveWorld("Jupiter", 63); resolveWorld("Saturn", 62); @@ -45,11 +45,12 @@ public class GalaxyService { createdWorld = new World(name, moons); createdWorld = worldRepository.save(createdWorld); } + return createdWorld; } public WorldDto findWorldNamed(String name) { - World world = worldRepository.findByPropertyValue("name", name); + World world = worldRepository.findByPropertyValue("name", name); return mapper.worldDtoFromWorld(world); } diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java deleted file mode 100644 index 1c17e10c1..000000000 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/MyWorldRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.transaction.annotation.Transactional; - -public interface MyWorldRepository { - @Transactional - void makeSureGalaxyIsNotEmpty(); - - World findWorldNamed(String name); - - Iterable findAllWorlds(); -} diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java index 0e54c1428..5c125e1d6 100644 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java +++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/World.java @@ -12,7 +12,7 @@ import java.util.Set; @NodeEntity public class World { @GraphId - Long id; + private Long id; @Indexed private String name; @@ -21,7 +21,7 @@ public class World { @Fetch @RelatedTo(type = RelationshipTypes.REACHABLE_BY_ROCKET, direction = Direction.BOTH) - Set reachableByRocket = new HashSet(); + private Set reachableByRocket = new HashSet(); public World(String name, int moons) { this.name = name; @@ -31,6 +31,10 @@ public class World { public World() { } + public Long getId() { + return id; + } + public String getName() { return name; } @@ -41,7 +45,7 @@ public class World { @Override public String toString() { - return String.format("World{name='%s, moons=%d}", name, moons); + return String.format("World{name='%s', moons=%d}", name, moons); } public void addRocketRouteTo(World otherWorld) { diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java index b693f5c8a..859395eca 100644 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java +++ b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepository.java @@ -6,5 +6,5 @@ import org.springframework.data.neo4j.repository.GraphRepository; * @author mh * @since 01.04.11 */ -public interface WorldRepository extends MyWorldRepository, GraphRepository { +public interface WorldRepository extends GraphRepository { } diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java b/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java deleted file mode 100644 index 3ee1aaeab..000000000 --- a/spring-data-neo4j-examples/hello-worlds/src/main/java/org/springframework/data/neo4j/examples/hellograph/WorldRepositoryImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.springframework.data.neo4j.examples.hellograph; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -/** - * Spring Data Neo4j backed application context for Worlds. - */ -public class WorldRepositoryImpl implements MyWorldRepository { - - @Autowired - private WorldRepository worldRepository; - - @Override - @Transactional - public void makeSureGalaxyIsNotEmpty() { - // Solar worlds - resolveWorld("Mercury", 0); - resolveWorld("Venus", 0); - - World earth = resolveWorld("Earth", 1); - World mars = resolveWorld("Mars", 2); - mars.addRocketRouteTo(earth); - - resolveWorld("Jupiter", 63); - resolveWorld("Saturn", 62); - resolveWorld("Uranus", 27); - resolveWorld("Neptune", 13); - - // Norse worlds - resolveWorld("Alfheimr", 0); - resolveWorld("Midgard", 1); - resolveWorld("Muspellheim", 2); - resolveWorld("Asgard", 63); - resolveWorld("Hel", 62); - } - - private World resolveWorld(String name, int moons) { - World createdWorld = findWorldNamed(name); - if (createdWorld == null) { - createdWorld = new World(name, moons); - worldRepository.save(createdWorld); - } - return createdWorld; - } - - @Override - public World findWorldNamed(String name) { - return worldRepository.findByPropertyValue("name", name); - } - - @Override - public Iterable findAllWorlds() { - return worldRepository.findAll(); - } -} diff --git a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml similarity index 51% rename from spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml rename to spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml index d925ed2bd..f4d652b9b 100644 --- a/spring-data-neo4j-examples/hello-worlds-aspects/src/main/resources/spring/helloWorldContext.xml +++ b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/aspects/helloWorldContext.xml @@ -1,16 +1,22 @@ - + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/data/neo4j + http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> + diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml deleted file mode 100644 index e442c40a5..000000000 --- a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/helloWorldContext.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - diff --git a/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml new file mode 100644 index 000000000..20647b299 --- /dev/null +++ b/spring-data-neo4j-examples/hello-worlds/src/main/resources/spring/plain/helloWorldContext.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java b/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java index a8b9ed43b..eccdc40a1 100644 --- a/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java +++ b/spring-data-neo4j-examples/hello-worlds/src/test/java/org/springframework/data/neo4j/examples/hellograph/GalaxyServiceTest.java @@ -34,7 +34,7 @@ public class GalaxyServiceTest { } @Test - public void populatedGalaxyShouldHaveEarth() { + public void populatedGalaxyShouldHaveEarth() { galaxyService.makeSureGalaxyIsNotEmpty(); WorldDto earth = galaxyService.findWorldNamed("Earth"); assertNotNull(earth); @@ -55,4 +55,5 @@ public class GalaxyServiceTest { WorldDto planetPopsicle = galaxyService.findWorldNamed("Krypton"); assertNull(planetPopsicle); } + }