Permalink
Browse files

Removed the server examples.

  • Loading branch information...
nawroth committed Feb 8, 2011
1 parent 789b7df commit 3db76baf409c9c1dcfdfd7b6776632daaa0cd8a1
View
60 pom.xml
@@ -4,13 +4,17 @@
<artifactId>neo4j-examples</artifactId>
<name>Neo4j Examples</name>
<version>1.3-SNAPSHOT</version>
- <description>Neo4j Distribution and examples</description>
+ <description>Neo4j Embedded Examples</description>
<url>http://components.neo4j.org/${project.artifactId}/${project.version}/</url>
<parent>
<groupId>org.neo4j.examples</groupId>
<artifactId>examples-pom</artifactId>
- <version>8</version>
+ <version>17</version>
</parent>
+
+ <scm>
+ <url>https://github.com/neo4j/examples</url>
+ </scm>
<properties>
<short-name>neo4j-examples</short-name>
@@ -19,12 +23,6 @@
<license-text.header>ApacheLicense-2.0-header.txt</license-text.header>
</properties>
- <scm>
- <connection>scm:svn:https://svn.neo4j.org/examples/neo4j-examples/trunk</connection>
- <developerConnection>scm:svn:https://svn.neo4j.org/examples/neo4j-examples/trunk</developerConnection>
- <url>https://trac.neo4j.org/browser/examples/neo4j-examples/</url>
- </scm>
-
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
@@ -47,14 +45,9 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-udc</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>1.3-SNAPSHOT</version>
<classifier>neo4j</classifier>
</dependency>
- <dependency>
- <groupId>org.neo4j.app</groupId>
- <artifactId>neo4j-server</artifactId>
- <version>0.6-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
@@ -63,27 +56,6 @@
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
- <!-- Server example dependencies -->
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-jaxrs</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>1.4</version>
- </dependency>
</dependencies>
<licenses>
@@ -222,6 +194,8 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
+ <!-- skip building the download assembly -->
+ <!--
<execution>
<id>download-assembly</id>
<phase>package</phase>
@@ -236,6 +210,7 @@
<goal>single</goal>
</goals>
</execution>
+ -->
<execution>
<id>site-assembly</id>
<phase>package</phase>
@@ -307,22 +282,9 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <tagBase>https://svn.neo4j.org/examples/${short-name}/tags</tagBase>
- </configuration>
- </plugin>
</plugins>
</build>
- <repositories>
- <repository>
- <id>java.net</id>
- <url>http://download.java.net/maven/2/</url>
- </repository>
- </repositories>
-
<reporting>
<plugins>
<plugin>
@@ -344,8 +306,6 @@
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
- <!-- remove version after upgrade to parent-central:11 -->
- <version>2.2</version>
<configuration>
<linkJavadoc>false</linkJavadoc>
</configuration>
@@ -1,164 +0,0 @@
-/**
- * Licensed to Neo Technology under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Neo Technology licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.neo4j.examples.server;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.ws.rs.core.MediaType;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-
-public class CreateSimpleGraph {
-
- private static final String SERVER_ROOT_URI = "http://localhost:7474/db/data/";
-
- public static void main(String[] args) throws URISyntaxException {
- checkDatabaseIsRunning();
-
- // START SNIPPET: nodesAndProps
- URI firstNode = createNode();
- addProperty(firstNode, "name", "Joe Strummer");
- URI secondNode = createNode();
- addProperty(secondNode, "band", "The Clash");
- // END SNIPPET: nodesAndProps
-
- // START SNIPPET: addRel
- URI relationshipUri = addRelationship(firstNode, secondNode, "singer", "{ \"from\" : \"1976\", \"until\" : \"1986\" }");
- // END SNIPPET: addRel
-
- // START SNIPPET: addMetaToRel
- addMetadataToProperty(relationshipUri, "stars", "5");
- // END SNIPPET: addMetaToRel
-
- // START SNIPPET: queryForSingers
- findSingersInBands(firstNode);
- // END SNIPPET: queryForSingers
- }
-
- private static void findSingersInBands(URI startNode) throws URISyntaxException {
- // START SNIPPET: traversalDesc
- // TraversalDescription turns into JSON to send to the Server
- TraversalDescription t = new TraversalDescription();
- t.setOrder(TraversalDescription.DEPTH_FIRST);
- t.setUniqueness(TraversalDescription.NODE);
- t.setMaxDepth(10);
- t.setReturnFilter(TraversalDescription.ALL);
- t.setRelationships(new Relationship("singer", Relationship.OUT));
- // END SNIPPET: traversalDesc
-
- // START SNIPPET: traverse
- URI traverserUri = new URI(startNode.toString() + "/traverse/node");
- WebResource resource = Client.create().resource(traverserUri);
- String jsonTraverserPayload = t.toJson();
- ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity(jsonTraverserPayload).post(ClientResponse.class);
-
- System.out.println(String.format("POST [%s] to [%s], status code [%d], returned data: " + System.getProperty("line.separator") + "%s", jsonTraverserPayload, traverserUri, response.getStatus(), response.getEntity(String.class)));
- // END SNIPPET: traverse
- }
-
- // START SNIPPET: insideAddMetaToProp
- private static void addMetadataToProperty(URI relationshipUri, String name, String value) throws URISyntaxException {
- URI propertyUri = new URI(relationshipUri.toString() + "/properties");
- WebResource resource = Client.create().resource(propertyUri);
-
- String entity = toJsonNameValuePairCollection(name, value);
- ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity(entity).put(ClientResponse.class);
-
- System.out.println(String.format("PUT [%s] to [%s], status code [%d]", entity, propertyUri, response.getStatus()));
- }
- // END SNIPPET: insideAddMetaToProp
-
- private static String toJsonNameValuePairCollection(String name, String value) {
- return String.format("{ \"%s\" : \"%s\" }", name, value);
- }
-
- private static URI createNode() {
- // START SNIPPET: createNode
- final String nodeEntryPointUri = SERVER_ROOT_URI + "node"; // http://localhost:7474/db/manage/node
-
- WebResource resource = Client.create().resource(nodeEntryPointUri); // http://localhost:7474/db/data/node
- ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity("{}").post(ClientResponse.class); // POST {} to the node entry point URI
-
- System.out.println(String.format("POST to [%s], status code [%d], location header [%s]", nodeEntryPointUri, response.getStatus(), response.getLocation().toString()));
-
- return response.getLocation();
- // END SNIPPET: createNode
- }
-
- // START SNIPPET: insideAddRel
- private static URI addRelationship(URI startNode, URI endNode, String relationshipType, String jsonAttributes) throws URISyntaxException {
- URI fromUri = new URI(startNode.toString() + "/relationships");
- String relationshipJson = generateJsonRelationship(endNode, relationshipType, jsonAttributes);
-
- WebResource resource = Client.create().resource(fromUri);
- ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity(relationshipJson).post(ClientResponse.class); // POST JSON to the relationships URI
-
- System.out.println(String.format("POST to [%s], status code [%d], location header [%s]", fromUri, response.getStatus(), response.getLocation().toString()));
-
- return response.getLocation();
- }
- // END SNIPPET: insideAddRel
-
- private static String generateJsonRelationship(URI endNode, String relationshipType, String ... jsonAttributes) {
- StringBuilder sb = new StringBuilder();
- sb.append("{ \"to\" : \"");
- sb.append(endNode.toString());
- sb.append("\", ");
-
- sb.append("\"type\" : \"");
- sb.append(relationshipType);
- if(jsonAttributes == null || jsonAttributes.length < 1) {
- sb.append("\"");
- } else {
- sb.append("\", \"data\" : ");
- for(int i = 0; i < jsonAttributes.length; i++) {
- sb.append(jsonAttributes[i]);
- if(i < jsonAttributes.length -1) { // Miss off the final comma
- sb.append(", ");
- }
- }
- }
-
- sb.append(" }");
- return sb.toString();
- }
-
- private static void addProperty(URI nodeUri, String propertyName, String propertyValue) {
- // START SNIPPET: addProp
- String propertyUri = nodeUri.toString() + "/properties/" + propertyName;
-
- WebResource resource = Client.create().resource(propertyUri); // http://localhost:7474/db/data/node/{node_id}/properties/{property_name}
- ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).entity("\"" + propertyValue + "\"").put(ClientResponse.class);
-
- System.out.println(String.format("PUT to [%s], status code [%d]", propertyUri, response.getStatus()));
- // END SNIPPET: addProp
- }
-
- private static void checkDatabaseIsRunning() {
- // START SNIPPET: checkServer
- WebResource resource = Client.create().resource(SERVER_ROOT_URI);
- ClientResponse response = resource.get(ClientResponse.class);
-
- System.out.println(String.format("GET on [%s], status code [%d]", SERVER_ROOT_URI, response.getStatus()));
- // END SNIPPET: checkServer
- }
-}
@@ -1,57 +0,0 @@
-/**
- * Licensed to Neo Technology under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Neo Technology licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.neo4j.examples.server;
-
-public class Relationship {
-
- public static final String OUT = "out";
- public static final String IN = "in";
- public static final String BOTH = "both";
- private String type;
- private String direction;
-
- public String toJsonCollection() {
- StringBuilder sb = new StringBuilder();
- sb.append("{ ");
- sb.append(" \"type\" : \"" + type + "\"");
- if(direction != null) {
- sb.append(", \"direction\" : \"" + direction + "\"");
- }
- sb.append(" }");
- return sb.toString();
- }
-
- public Relationship(String type, String direction) {
- setType(type);
- setDirection(direction);
- }
-
-
- public Relationship(String type) {
- this(type, null);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void setDirection(String direction) {
- this.direction = direction;
- }
-}
Oops, something went wrong.

0 comments on commit 3db76ba

Please sign in to comment.