Permalink
Browse files

initial import

  • Loading branch information...
DirkMahler committed Nov 4, 2013
1 parent 9bca024 commit 981fcaba4a91a3d1095f0e76f8dca2a3d94c1514
Showing with 1,654 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +11 −0 api/pom.xml
  3. +26 −0 api/src/main/java/com/buschmais/cdo/api/CdoManager.java
  4. +12 −0 api/src/main/java/com/buschmais/cdo/api/CdoManagerException.java
  5. +8 −0 api/src/main/java/com/buschmais/cdo/api/CdoManagerFactory.java
  6. +34 −0 api/src/main/java/com/buschmais/cdo/api/QueryResult.java
  7. +157 −0 neo4j/pom.xml
  8. +4 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Id.java
  9. +8 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Indexed.java
  10. +10 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Label.java
  11. +5 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Property.java
  12. +5 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Relation.java
  13. +38 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/AbstractNeo4jCdoManagerFactoryImpl.java
  14. +180 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/CdoManagerImpl.java
  15. +25 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/EmbeddedNeo4jCdoManagerFactoryImpl.java
  16. +67 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/QueryResultImpl.java
  17. +19 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/AbstractPropertyMetadata.java
  18. +17 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/AbstractRelationshipPropertyMetadata.java
  19. +11 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/CollectionPropertyMetadata.java
  20. +49 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/NodeMetadata.java
  21. +206 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/NodeMetadataProvider.java
  22. +15 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/PrimitivePropertyMetadata.java
  23. +11 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/metadata/ReferencePropertyMetadata.java
  24. +114 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/InstanceManager.java
  25. +26 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/NodeInvocationHandler.java
  26. +80 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/collection/SetProxy.java
  27. +23 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/AbstractPropertyMethod.java
  28. +25 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/CollectionPropertyGetMethod.java
  29. +31 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/CollectionPropertySetMethod.java
  30. +24 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/EqualsMethod.java
  31. +11 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/HashCodeMethod.java
  32. +20 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/PrimitivePropertyGetMethod.java
  33. +25 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/PrimitivePropertySetMethod.java
  34. +7 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/ProxyMethod.java
  35. +25 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/ReferencePropertyGetMethod.java
  36. +29 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/ReferencePropertySetMethod.java
  37. +20 −0 neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/proxy/method/ToStringMethod.java
  38. +28 −0 neo4j/src/test/java/com/buschmais/cdo/neo4j/test/A.java
  39. +7 −0 neo4j/src/test/java/com/buschmais/cdo/neo4j/test/B.java
  40. +7 −0 neo4j/src/test/java/com/buschmais/cdo/neo4j/test/C.java
  41. +133 −0 neo4j/src/test/java/com/buschmais/cdo/neo4j/test/EmbeddedNeo4jCdoManagerTest.java
  42. +8 −0 neo4j/src/test/java/com/buschmais/cdo/neo4j/test/Version.java
  43. +84 −0 pom.xml
@@ -0,0 +1,9 @@
target
.settings
.shell_history
.project
.classpath

/.idea

*.iml
@@ -0,0 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.buschmais.cdo</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>cdo.api</artifactId>

</project>
@@ -0,0 +1,26 @@
package com.buschmais.cdo.api;

import com.buschmais.cdo.api.QueryResult;

import java.util.Map;

public interface CdoManager {

void begin();

void commit();

void rollback();

<T> Iterable<T> find(Class<T> type, Object value);

<T> T create(Class<T> type);

<T> void remove(T instance);

QueryResult executeQuery(String query);

QueryResult executeQuery(String query, Map<String, Object> parameters);

void close();
}
@@ -0,0 +1,12 @@
package com.buschmais.cdo.api;

public class CdoManagerException extends RuntimeException {

public CdoManagerException(String message) {
super(message);
}

public CdoManagerException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -0,0 +1,8 @@
package com.buschmais.cdo.api;

public interface CdoManagerFactory {

CdoManager createCdoManager();

void close();
}
@@ -0,0 +1,34 @@
package com.buschmais.cdo.api;

import java.util.List;
import java.util.Map;

public interface QueryResult {

/**
* A row of a query result containing named columns and their values.
*/
public static class Row {

private Map<String, Object> row;

public Row(Map<String, Object> row) {
this.row = row;
}

@SuppressWarnings("unchecked")
public <T> T get(String column) {
return (T) row.get(column);
}

public Map<String, Object> get() {
return row;
}
}

List<String> getColumns();

Iterable<QueryResult.Row> getRows();

void close();
}
@@ -0,0 +1,157 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.buschmais.cdo</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>cdo.neo4j</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.neo4j_version>2.0.0-M06</org.neo4j_version>
</properties>

<repositories>
<repository>
<id>neo4j-releases</id>
<url>http://m2.neo4j.org/content/repositories/releases</url>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>server-api</artifactId>
<version>${org.neo4j_version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${org.neo4j_version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
<version>${org.neo4j_version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${org.neo4j_version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${org.neo4j_version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<classifier>static-web</classifier>
<version>${org.neo4j_version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-rest-graphdb</artifactId>
<version>${org.neo4j_version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.buschmais.cdo</groupId>
<artifactId>cdo.api</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<classifier>static-web</classifier>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,4 @@
package com.buschmais.cdo.neo4j.annotation;

public @interface Id {
}
@@ -0,0 +1,8 @@
package com.buschmais.cdo.neo4j.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface Indexed {
}
@@ -0,0 +1,10 @@
package com.buschmais.cdo.neo4j.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface Label {

String value();
}
@@ -0,0 +1,5 @@
package com.buschmais.cdo.neo4j.annotation;

public @interface Property {
String value();
}
@@ -0,0 +1,5 @@
package com.buschmais.cdo.neo4j.annotation;

public @interface Relation {
String value();
}
@@ -0,0 +1,38 @@
package com.buschmais.cdo.neo4j.impl;

import com.buschmais.cdo.api.CdoManager;
import com.buschmais.cdo.api.CdoManagerFactory;
import com.buschmais.cdo.neo4j.impl.metadata.NodeMetadataProvider;
import com.buschmais.cdo.neo4j.impl.proxy.InstanceManager;
import org.neo4j.graphdb.GraphDatabaseService;

import java.net.URL;
import java.util.Arrays;

public abstract class AbstractNeo4jCdoManagerFactoryImpl implements CdoManagerFactory {

private URL url;
private NodeMetadataProvider nodeMetadataProvider;
private ClassLoader classLoader;

public AbstractNeo4jCdoManagerFactoryImpl(URL url, Class<?>... entities) {
this.url = url;
nodeMetadataProvider = new NodeMetadataProvider(Arrays.asList(entities));
classLoader = new ClassLoader() {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
return super.loadClass(name);
}
};

}

@Override
public CdoManager createCdoManager() {
GraphDatabaseService graphDatabaseService = getGraphDatabaseService(url);
InstanceManager instanceManager = new InstanceManager(nodeMetadataProvider, classLoader);
return new CdoManagerImpl(nodeMetadataProvider, graphDatabaseService, instanceManager);
}

protected abstract GraphDatabaseService getGraphDatabaseService(URL url);
}
Oops, something went wrong.

0 comments on commit 981fcab

Please sign in to comment.