-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bca024
commit 981fcab
Showing
43 changed files
with
1,654 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
target | ||
.settings | ||
.shell_history | ||
.project | ||
.classpath | ||
|
||
/.idea | ||
|
||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
api/src/main/java/com/buschmais/cdo/api/CdoManagerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
api/src/main/java/com/buschmais/cdo/api/CdoManagerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
4 changes: 4 additions & 0 deletions
4
neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Id.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.buschmais.cdo.neo4j.annotation; | ||
|
||
public @interface Id { | ||
} |
8 changes: 8 additions & 0 deletions
8
neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Indexed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Label.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
5 changes: 5 additions & 0 deletions
5
neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Property.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
5 changes: 5 additions & 0 deletions
5
neo4j/src/main/java/com/buschmais/cdo/neo4j/annotation/Relation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
38 changes: 38 additions & 0 deletions
38
neo4j/src/main/java/com/buschmais/cdo/neo4j/impl/AbstractNeo4jCdoManagerFactoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.