Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkMahler committed Nov 4, 2013
1 parent 9bca024 commit 981fcab
Show file tree
Hide file tree
Showing 43 changed files with 1,654 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target
.settings
.shell_history
.project
.classpath

/.idea

*.iml
11 changes: 11 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
26 changes: 26 additions & 0 deletions api/src/main/java/com/buschmais/cdo/api/CdoManager.java
Original file line number Diff line number Diff line change
@@ -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();
}
12 changes: 12 additions & 0 deletions api/src/main/java/com/buschmais/cdo/api/CdoManagerException.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.buschmais.cdo.api;

public interface CdoManagerFactory {

CdoManager createCdoManager();

void close();
}
34 changes: 34 additions & 0 deletions api/src/main/java/com/buschmais/cdo/api/QueryResult.java
Original file line number Diff line number Diff line change
@@ -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();
}
157 changes: 157 additions & 0 deletions neo4j/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.buschmais.cdo.neo4j.annotation;

public @interface Id {
}
Original file line number Diff line number Diff line change
@@ -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 {
}
10 changes: 10 additions & 0 deletions neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Label.java
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.buschmais.cdo.neo4j.annotation;

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

public @interface Relation {
String value();
}
Original file line number Diff line number Diff line change
@@ -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);
}
Loading

0 comments on commit 981fcab

Please sign in to comment.