├── src ├── main │ ├── resources │ │ └── META_INF │ │ │ └── services │ │ │ └── org.neo4j.server.plugins.ServerPlugin │ └── java │ │ └── org │ │ └── neo4j │ │ └── good_practices │ │ ├── Printer.java │ │ ├── SystemPrinter.java │ │ ├── PrinterProvider.java │ │ ├── SecurityRuleA.java │ │ ├── SecurityRuleB.java │ │ ├── ColleagueFinderExtension.java │ │ └── ColleagueFinder.java └── test │ └── java │ └── org │ └── neo4j │ └── good_practices │ ├── Migration.java │ ├── ColleagueFinderTest.java │ ├── ColleagueFinderExtensionTest.java │ ├── DatabaseFixture.java │ ├── NewOpportunitiesForConnectedData.java │ └── ExampleData.java ├── README.md ├── .gitignore ├── data └── dbms │ └── authorization └── pom.xml /src/main/resources/META_INF/services/org.neo4j.server.plugins.ServerPlugin: -------------------------------------------------------------------------------- 1 | org.neo4j.good_practices.ColleagueFinderExtension -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | neo4j-good-practices 2 | ==================== 3 | 4 | Code to accompany presentation on Neo4j development practices -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | target 4 | .idea 5 | *.iml 6 | .project 7 | .classpath 8 | .settings 9 | lib 10 | out 11 | .repo -------------------------------------------------------------------------------- /data/dbms/authorization: -------------------------------------------------------------------------------- 1 | neo4j::SHA-256,05AAF8DACC5E3C03EC4D5A90C6A41CCB7FDDE4F97748B62DBAD15CF6AD8AB6E1,EA399C75F89647F03A71E8F7664BE24F:password_change_required 2 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/Printer.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | public interface Printer 4 | { 5 | void printLine( String value ); 6 | } 7 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/Migration.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import org.neo4j.graphdb.GraphDatabaseService; 4 | 5 | public interface Migration 6 | { 7 | void apply(GraphDatabaseService db); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/SystemPrinter.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | public class SystemPrinter implements Printer 4 | { 5 | public void printLine( String value ) 6 | { 7 | System.out.println( value ); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/PrinterProvider.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import javax.ws.rs.core.Context; 4 | import javax.ws.rs.ext.Provider; 5 | 6 | import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider; 7 | 8 | @Provider 9 | public class PrinterProvider extends SingletonTypeInjectableProvider 10 | { 11 | public PrinterProvider() 12 | { 13 | super( Printer.class, new SystemPrinter() ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/SecurityRuleA.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.neo4j.server.rest.security.SecurityRule; 6 | 7 | public class SecurityRuleA implements SecurityRule 8 | { 9 | @Override 10 | public boolean isAuthorized( HttpServletRequest httpServletRequest ) 11 | { 12 | httpServletRequest.setAttribute( "X-Neo4j", "2.0.3" ); 13 | return true; 14 | } 15 | 16 | @Override 17 | public String forUriPath() 18 | { 19 | return "/*"; 20 | } 21 | 22 | @Override 23 | public String wwwAuthenticateHeader() 24 | { 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/SecurityRuleB.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.util.Date; 4 | import java.util.UUID; 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import org.neo4j.server.rest.security.SecurityRule; 8 | 9 | public class SecurityRuleB implements SecurityRule 10 | { 11 | @Override 12 | public boolean isAuthorized( HttpServletRequest httpServletRequest ) 13 | { 14 | httpServletRequest.setAttribute( "X-Id", UUID.randomUUID() ); 15 | return true; 16 | } 17 | 18 | @Override 19 | public String forUriPath() 20 | { 21 | return "/*"; 22 | } 23 | 24 | @Override 25 | public String wwwAuthenticateHeader() 26 | { 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/ColleagueFinderTest.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.util.Collections; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | 11 | import org.neo4j.graphdb.Result; 12 | 13 | import static org.junit.Assert.assertEquals; 14 | import static org.junit.Assert.assertFalse; 15 | 16 | public class ColleagueFinderTest 17 | { 18 | private DatabaseFixture dbFixture; 19 | private ColleagueFinder finder; 20 | 21 | @Before 22 | public void init() 23 | { 24 | dbFixture = DatabaseFixture.createDatabase() 25 | .populateWith( ExampleData.smallGraph ) 26 | .applyMigrations( Collections.emptyList() ); 27 | 28 | finder = new ColleagueFinder( dbFixture.database() ); 29 | } 30 | 31 | @After 32 | public void shutdown() 33 | { 34 | dbFixture.shutdown(); 35 | } 36 | 37 | @Test 38 | public void shouldFindColleaguesWithSimilarSkills() throws Exception 39 | { 40 | // when 41 | Result result = finder.findColleaguesFor( "Ian" ); 42 | 43 | // then 44 | assertEquals( "Lucy", result.next().get( "name" ) ); 45 | assertEquals( "Bill", result.next().get( "name" ) ); 46 | 47 | assertFalse( result.hasNext() ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/ColleagueFinderExtension.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.io.IOException; 4 | import javax.ws.rs.GET; 5 | import javax.ws.rs.Path; 6 | import javax.ws.rs.PathParam; 7 | import javax.ws.rs.Produces; 8 | import javax.ws.rs.core.Context; 9 | import javax.ws.rs.core.MediaType; 10 | import javax.ws.rs.core.Response; 11 | 12 | import com.sun.jersey.api.core.PackagesResourceConfig; 13 | import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider; 14 | import org.codehaus.jackson.map.ObjectMapper; 15 | 16 | import org.neo4j.graphdb.GraphDatabaseService; 17 | import org.neo4j.helpers.collection.IteratorUtil; 18 | 19 | @Path("/similar-skills") 20 | public class ColleagueFinderExtension 21 | { 22 | private static final ObjectMapper MAPPER = new ObjectMapper(); 23 | 24 | private final ColleagueFinder colleagueFinder; 25 | private final Printer printer; 26 | 27 | public ColleagueFinderExtension( @Context GraphDatabaseService db, @Context Printer printer ) 28 | { 29 | this.colleagueFinder = new ColleagueFinder( db ); 30 | this.printer = printer; 31 | } 32 | 33 | @GET 34 | @Produces(MediaType.APPLICATION_JSON) 35 | @Path("/{name}") 36 | public Response getColleagues( @PathParam("name") String name ) throws IOException 37 | { 38 | printer.printLine( "GetColleagues() invoked" ); 39 | 40 | String json = MAPPER.writeValueAsString( 41 | IteratorUtil.asCollection( colleagueFinder.findColleaguesFor( name ) ) ); 42 | 43 | return Response.ok().entity( json ).build(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/ColleagueFinderExtensionTest.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | import java.util.Map; 6 | import javax.ws.rs.core.MediaType; 7 | 8 | import com.sun.jersey.api.client.Client; 9 | import com.sun.jersey.api.client.ClientResponse; 10 | import com.sun.jersey.api.client.WebResource; 11 | import com.sun.jersey.api.client.config.DefaultClientConfig; 12 | import org.codehaus.jackson.map.ObjectMapper; 13 | import org.junit.After; 14 | import org.junit.Before; 15 | import org.junit.Test; 16 | 17 | import org.neo4j.harness.ServerControls; 18 | import org.neo4j.harness.TestServerBuilders; 19 | import org.neo4j.test.server.HTTP; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | import static org.junit.Assert.assertThat; 23 | import static org.junit.matchers.JUnitMatchers.hasItems; 24 | 25 | public class ColleagueFinderExtensionTest 26 | { 27 | private ServerControls server; 28 | 29 | @Before 30 | public void startServer() throws IOException 31 | { 32 | server = TestServerBuilders.newInProcessBuilder() 33 | .withExtension( "/colleagues", ColleagueFinderExtension.class ) 34 | .withFixture( ExampleData.smallGraph ) 35 | .newServer(); 36 | } 37 | 38 | @After 39 | public void stopServer() 40 | { 41 | server.close(); 42 | } 43 | 44 | @Test 45 | @SuppressWarnings("unchecked") 46 | public void shouldReturnColleaguesWithSimilarSkills() throws Exception 47 | { 48 | HTTP.Response response = HTTP.GET( server.httpURI().resolve( "/colleagues/similar-skills/Ian" ).toString() ); 49 | 50 | assertEquals( 200, response.status() ); 51 | assertEquals( MediaType.APPLICATION_JSON, response.header( "Content-Type" )); 52 | 53 | List> results = new ObjectMapper().readValue( response.rawContent( ), List.class ); 54 | 55 | assertEquals( "Lucy", results.get( 0 ).get( "name" ) ); 56 | assertThat( (Iterable) results.get( 0 ).get( "skills" ), hasItems( "Java", "Neo4j" ) ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/DatabaseFixture.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.util.Collections; 4 | 5 | import org.neo4j.graphdb.GraphDatabaseService; 6 | import org.neo4j.graphdb.Result; 7 | import org.neo4j.test.TestGraphDatabaseFactory; 8 | 9 | public class DatabaseFixture 10 | { 11 | public static DatabaseFixtureBuilder createDatabase() 12 | { 13 | return new DatabaseFixtureBuilder( new TestGraphDatabaseFactory() 14 | .newImpermanentDatabaseBuilder() 15 | .newGraphDatabase() ); 16 | } 17 | 18 | public static DatabaseFixtureBuilder useExistingDatabase( GraphDatabaseService db ) 19 | { 20 | return new DatabaseFixtureBuilder( db ); 21 | } 22 | 23 | private final GraphDatabaseService db; 24 | 25 | private DatabaseFixture( GraphDatabaseService db, String initialContents, Iterable migrations ) 26 | { 27 | this.db = db; 28 | 29 | populateWith( initialContents ); 30 | applyMigrations( migrations ); 31 | } 32 | 33 | public GraphDatabaseService database() 34 | { 35 | return db; 36 | } 37 | 38 | public void shutdown() 39 | { 40 | db.shutdown(); 41 | } 42 | 43 | private Result populateWith( String cypher ) 44 | { 45 | return db.execute( cypher ); 46 | } 47 | 48 | private void applyMigrations( Iterable migrations ) 49 | { 50 | for ( Migration migration : migrations ) 51 | { 52 | migration.apply( db ); 53 | } 54 | } 55 | 56 | public static class DatabaseFixtureBuilder 57 | { 58 | private final GraphDatabaseService db; 59 | private String initialContents; 60 | 61 | private DatabaseFixtureBuilder( GraphDatabaseService db ) 62 | { 63 | this.db = db; 64 | } 65 | 66 | public DatabaseFixtureBuilder populateWith( String cypher ) 67 | { 68 | initialContents = cypher; 69 | return this; 70 | } 71 | 72 | public DatabaseFixture applyMigrations( Iterable migrations ) 73 | { 74 | return new DatabaseFixture( db, initialContents, migrations ); 75 | } 76 | 77 | public DatabaseFixture noMigrations() 78 | { 79 | return new DatabaseFixture( db, initialContents, Collections.emptyList() ); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/neo4j/good_practices/ColleagueFinder.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | 7 | import org.neo4j.cypher.javacompat.ExecutionEngine; 8 | import org.neo4j.graphdb.GraphDatabaseService; 9 | import org.neo4j.graphdb.Result; 10 | 11 | public class ColleagueFinder 12 | { 13 | private final GraphDatabaseService db; 14 | 15 | public ColleagueFinder( GraphDatabaseService db ) 16 | { 17 | this.db = db; 18 | } 19 | 20 | public Result findColleaguesFor( String name ) 21 | { 22 | String cypher = 23 | "MATCH (company)<-[:WORKS_FOR]-(me:Person)-[:HAS_SKILL]->(skill),\n" + 24 | " (company)<-[:WORKS_FOR]-(colleague)-[:HAS_SKILL]->(skill)\n" + 25 | "WHERE me.name = {name}\n" + 26 | "RETURN colleague.name AS name,\n" + 27 | " count(skill) AS score,\n" + 28 | " collect(skill.name) AS skills\n" + 29 | "ORDER BY score DESC"; 30 | 31 | Map params = new HashMap(); 32 | params.put( "name", name ); 33 | 34 | return db.execute( cypher, params ); 35 | } 36 | 37 | public Result findPeopleFor( String name ) 38 | { 39 | String cypher = 40 | "MATCH (me:Person)-[:HAS_SKILL]->(skill),\n" + 41 | " (company)<-[:WORKS_FOR]-(person)-[:HAS_SKILL]->(skill)\n" + 42 | "WHERE me.name = {name}\n" + 43 | "RETURN person.name AS name,\n" + 44 | " company.name AS company,\n" + 45 | " count(skill) AS score,\n" + 46 | " collect(skill.name) AS skills\n" + 47 | "ORDER BY score DESC"; 48 | 49 | Map params = new HashMap(); 50 | params.put( "name", name ); 51 | 52 | return db.execute( cypher, params ); 53 | } 54 | 55 | public Result findWithMatchingSkills( String name, String... skills ) 56 | { 57 | String cypher = "MATCH p=(me:Person)-[:WORKED_ON*2..4]-\n" + 58 | " (person)-[:HAS_SKILL]->(skill)\n" + 59 | "WHERE me.name = {name}\n" + 60 | " AND person <> me \n" + 61 | " AND skill.name IN {skills}\n" + 62 | "WITH person, skill, min(length(p)) as pathLength\n" + 63 | "RETURN person.name AS name,\n" + 64 | " count(skill) AS score,\n" + 65 | " collect(skill.name) AS skills,\n" + 66 | " ((pathLength - 1)/2) AS distance\n" + 67 | "ORDER BY score DESC;"; 68 | 69 | Map params = new HashMap(); 70 | params.put( "name", name ); 71 | params.put( "skills", skills ); 72 | 73 | return db.execute( cypher, params ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | neo4j-good-practices 8 | neo4j-good-practices 9 | 1.0 10 | 11 | 12 | 13 | org.neo4j 14 | neo4j 15 | 2.2.0 16 | 17 | 18 | org.neo4j.app 19 | neo4j-server 20 | 2.2.0 21 | 22 | 23 | org.neo4j.test 24 | neo4j-harness 25 | 2.2.0 26 | 27 | 28 | org.neo4j.app 29 | neo4j-server 30 | 2.2.0 31 | test-jar 32 | test 33 | 34 | 35 | org.neo4j 36 | neo4j-kernel 37 | 2.2.0 38 | test-jar 39 | test 40 | 41 | 42 | junit 43 | junit 44 | 4.7 45 | test 46 | 47 | 48 | com.sun.jersey 49 | jersey-server 50 | 1.17 51 | 52 | 53 | com.sun.jersey 54 | jersey-servlet 55 | 1.17 56 | 57 | 58 | com.sun.jersey 59 | jersey-client 60 | 1.17 61 | 62 | 63 | com.sun.jersey 64 | jersey-core 65 | 1.17 66 | 67 | 68 | org.codehaus.jackson 69 | jackson-core-asl 70 | 1.9.13 71 | 72 | 73 | org.codehaus.jackson 74 | jackson-mapper-asl 75 | 1.9.13 76 | 77 | 78 | org.mortbay.jetty 79 | jetty 80 | 6.1.25 81 | 82 | 83 | org.apache.httpcomponents 84 | httpclient 85 | 4.4.1 86 | test 87 | 88 | 89 | org.apache.httpcomponents 90 | httpcore 91 | 4.4.1 92 | test 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/NewOpportunitiesForConnectedData.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | import java.util.Collections; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | 7 | import org.junit.AfterClass; 8 | import org.junit.BeforeClass; 9 | import org.junit.Test; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertFalse; 13 | import static org.junit.Assert.assertThat; 14 | import static org.junit.matchers.JUnitMatchers.hasItems; 15 | 16 | public class NewOpportunitiesForConnectedData 17 | { 18 | private static DatabaseFixture dbFixture; 19 | private static ColleagueFinder finder; 20 | 21 | @BeforeClass 22 | public static void init() 23 | { 24 | dbFixture = DatabaseFixture.createDatabase() 25 | .populateWith( ExampleData.largeGraph ) 26 | .applyMigrations( Collections.emptyList() ); 27 | 28 | finder = new ColleagueFinder( dbFixture.database() ); 29 | } 30 | 31 | @AfterClass 32 | public static void shutdown() 33 | { 34 | dbFixture.shutdown(); 35 | } 36 | 37 | @Test 38 | @SuppressWarnings("unchecked") 39 | public void shouldFindColleaguesWithSimilarSkills() throws Exception 40 | { 41 | // when 42 | Iterator> results = finder.findColleaguesFor( "Ian" ); 43 | 44 | // then 45 | Map row = results.next(); 46 | assertEquals( "Ben", row.get( "name" ) ); 47 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Neo4j", "REST" ) ); 48 | 49 | row = results.next(); 50 | assertEquals( "Charlie", row.get( "name" ) ); 51 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Neo4j" ) ); 52 | 53 | assertFalse( results.hasNext() ); 54 | } 55 | 56 | @Test 57 | @SuppressWarnings("unchecked") 58 | public void shouldFindPeopleWithSimilarSkills() throws Exception 59 | { 60 | // when 61 | Iterator> results = finder.findPeopleFor( "Ian" ); 62 | 63 | // then 64 | Map row = results.next(); 65 | assertEquals( "Arnold", row.get( "name" ) ); 66 | assertEquals( "Startup, Ltd", row.get( "company" ) ); 67 | assertEquals( 3L, row.get( "score" ) ); 68 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Java", "Neo4j", "REST" ) ); 69 | 70 | row = results.next(); 71 | assertEquals( "Ben", row.get( "name" ) ); 72 | assertEquals( "Acme, Inc", row.get( "company" ) ); 73 | assertEquals( 2L, row.get( "score" ) ); 74 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Neo4j", "REST" ) ); 75 | 76 | row = results.next(); 77 | assertEquals( "Gordon", row.get( "name" ) ); 78 | assertEquals( "Startup, Ltd", row.get( "company" ) ); 79 | assertEquals( 1L, row.get( "score" ) ); 80 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Neo4j" ) ); 81 | 82 | row = results.next(); 83 | assertEquals( "Charlie", row.get( "name" ) ); 84 | assertEquals( "Acme, Inc", row.get( "company" ) ); 85 | assertEquals( 1L, row.get( "score" ) ); 86 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Neo4j" ) ); 87 | 88 | assertFalse( results.hasNext() ); 89 | } 90 | 91 | @Test 92 | @SuppressWarnings("unchecked") 93 | public void shouldFindPeopleWithMatchingSkills() throws Exception 94 | { 95 | // when 96 | Iterator> results = finder.findWithMatchingSkills( "Ian", "Java", "Clojure", "SQL" ); 97 | 98 | // then 99 | Map row = results.next(); 100 | assertEquals( "Arnold", row.get( "name" ) ); 101 | assertEquals( 2L, row.get( "score" ) ); 102 | assertEquals( 2L, row.get( "distance" ) ); 103 | assertThat( (Iterable) row.get( "skills" ), hasItems( "Clojure", "Java" ) ); 104 | 105 | row = results.next(); 106 | assertEquals( "Charlie", row.get( "name" ) ); 107 | assertEquals( 1L, row.get( "score" ) ); 108 | assertEquals( 1L, row.get( "distance" ) ); 109 | assertThat( (Iterable) row.get( "skills" ), hasItems( "SQL" ) ); 110 | 111 | assertFalse( results.hasNext() ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/test/java/org/neo4j/good_practices/ExampleData.java: -------------------------------------------------------------------------------- 1 | package org.neo4j.good_practices; 2 | 3 | public class ExampleData 4 | { 5 | public static String smallGraph = "CREATE (ian:Person {name:'Ian'}),\n" + 6 | " (bill:Person {name:'Bill'}),\n" + 7 | " (lucy:Person {name:'Lucy'}),\n" + 8 | " (acme:Company {name:'Acme'}),\n" + 9 | " (java:Skill {name:'Java'}),\n" + 10 | " (csharp:Skill {name:'C#'}),\n" + 11 | " (neo4j:Skill {name:'Neo4j'}),\n" + 12 | " (ruby:Skill {name:'Ruby'}),\n" + 13 | " (ian)-[:WORKS_FOR]->(acme),\n" + 14 | " (bill)-[:WORKS_FOR]->(acme),\n" + 15 | " (lucy)-[:WORKS_FOR]->(acme),\n" + 16 | " (ian)-[:HAS_SKILL]->(java),\n" + 17 | " (ian)-[:HAS_SKILL]->(csharp),\n" + 18 | " (ian)-[:HAS_SKILL]->(neo4j),\n" + 19 | " (bill)-[:HAS_SKILL]->(neo4j),\n" + 20 | " (bill)-[:HAS_SKILL]->(ruby),\n" + 21 | " (lucy)-[:HAS_SKILL]->(java),\n" + 22 | " (lucy)-[:HAS_SKILL]->(neo4j)"; 23 | 24 | public static String largeGraph = "CREATE\n" + 25 | "(ben:Person {name:'Ben'}),\n" + 26 | "(arnold:Person {name:'Arnold'}),\n" + 27 | "(charlie:Person {name:'Charlie'}),\n" + 28 | "(gordon:Person {name:'Gordon'}),\n" + 29 | "(lucy:Person {name:'Lucy'}),\n" + 30 | "(emily:Person {name:'Emily'}),\n" + 31 | "(ian:Person {name:'Ian'}),\n" + 32 | "(kate:Person {name:'Kate'}),\n" + 33 | "(acme:Company {name:'Acme, Inc'}),\n" + 34 | "(startup:Company {name:'Startup, Ltd'}),\n" + 35 | "(neo4j:Skill {name:'Neo4j'}),\n" + //graphs 36 | "(rest:Skill {name:'REST'}),\n" + 37 | "(dotNet:Skill {name:'DotNet'}),\n" + //art 38 | "(ruby:Skill {name:'Ruby'}),\n" + //design 39 | "(sql:Skill {name:'SQL'}),\n" + // medicine 40 | "(architecture:Skill {name:'Architecture'}),\n" + //drama 41 | "(java:Skill {name:'Java'}),\n" + 42 | "(python:Skill {name:'Python'}),\n" + //music 43 | "(javascript:Skill {name:'Javascript'}),\n" + //cars 44 | "(clojure:Skill {name:'Clojure'}),\n" + //travel 45 | "(phoenix:Project {name:'Phoenix'}),\n" + 46 | "(quantumLeap:Project {name:'Quantum Leap'}),\n" + 47 | "(nextGenPlatform:Project {name:'Next Gen Platform'}),\n" + 48 | "ben-[:WORKS_FOR]->acme,\n" + 49 | "charlie-[:WORKS_FOR]->acme,\n" + 50 | "lucy-[:WORKS_FOR]->acme,\n" + 51 | "ian-[:WORKS_FOR]->acme,\n" + 52 | "arnold-[:WORKS_FOR]->startup,\n" + 53 | "gordon-[:WORKS_FOR]->startup,\n" + 54 | "emily-[:WORKS_FOR]->startup,\n" + 55 | "kate-[:WORKS_FOR]->startup,\n" + 56 | "ben-[:HAS_SKILL]->neo4j,\n" + 57 | "ben-[:HAS_SKILL]->rest,\n" + 58 | "arnold-[:HAS_SKILL]->neo4j,\n" + 59 | "arnold-[:HAS_SKILL]->java,\n" + 60 | "arnold-[:HAS_SKILL]->rest,\n" + 61 | "arnold-[:HAS_SKILL]->clojure,\n" + 62 | "charlie-[:HAS_SKILL]->neo4j,\n" + 63 | "charlie-[:HAS_SKILL]->javascript,\n" + 64 | "charlie-[:HAS_SKILL]->sql,\n" + 65 | "gordon-[:HAS_SKILL]->neo4j,\n" + 66 | "gordon-[:HAS_SKILL]->dotNet,\n" + 67 | "gordon-[:HAS_SKILL]->python,\n" + 68 | "lucy-[:HAS_SKILL]->dotNet,\n" + 69 | "lucy-[:HAS_SKILL]->architecture,\n" + 70 | "lucy-[:HAS_SKILL]->python,\n" + 71 | "emily-[:HAS_SKILL]->dotNet,\n" + 72 | "emily-[:HAS_SKILL]->ruby,\n" + 73 | "ian-[:HAS_SKILL]->java,\n" + 74 | "ian-[:HAS_SKILL]->neo4j,\n" + 75 | "ian-[:HAS_SKILL]->rest,\n" + 76 | "kate-[:HAS_SKILL]->architecture,\n" + 77 | "kate-[:HAS_SKILL]->python,\n" + 78 | "arnold-[:WORKED_ON]->phoenix,\n" + 79 | "kate-[:WORKED_ON]->phoenix,\n" + 80 | "kate-[:WORKED_ON]->quantumLeap,\n" + 81 | "emily-[:WORKED_ON]->quantumLeap,\n" + 82 | "ben-[:WORKED_ON]->nextGenPlatform,\n" + 83 | "emily-[:WORKED_ON]->nextGenPlatform,\n" + 84 | "charlie-[:WORKED_ON]->nextGenPlatform,\n" + 85 | "ian-[:WORKED_ON]->nextGenPlatform,\n" + 86 | "ian-[:WORKED_ON]->quantumLeap"; 87 | } 88 | --------------------------------------------------------------------------------