Skip to content

Commit

Permalink
Adding EOAdaptor for Neo4J
Browse files Browse the repository at this point in the history
  • Loading branch information
Jedrzej Sobanski authored and Pascal Robert committed Jun 13, 2012
1 parent 4e9403b commit c3df2b2
Show file tree
Hide file tree
Showing 123 changed files with 5,975 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Frameworks/EOAdaptors/JavaNeo4JAdaptor/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="Sources"/>
<classpathentry kind="src" path="Tests"/>
<classpathentry kind="con" path="WOFramework/ERExtensions"/>
<classpathentry kind="con" path="WOFramework/ERJars"/>
<classpathentry kind="con" path="WOFramework/JavaWOExtensions"/>
<classpathentry kind="con" path="WOFramework/JavaEOAccess"/>
<classpathentry kind="con" path="WOFramework/JavaEOControl"/>
<classpathentry kind="con" path="WOFramework/JavaFoundation"/>
<classpathentry kind="con" path="WOFramework/JavaJDBCAdaptor"/>
<classpathentry kind="con" path="WOFramework/JavaWebObjects"/>
<classpathentry kind="con" path="WOFramework/JavaXML"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="Libraries/geronimo-jta_1.1_spec-1.1.1.jar"/>
<classpathentry kind="lib" path="Libraries/lucene-core-3.5.0.jar"/>
<classpathentry kind="lib" path="Libraries/org.apache.servicemix.bundles.jline-0.9.94_1.jar"/>
<classpathentry kind="lib" path="Libraries/scala-library-2.9.0-1.jar"/>
<classpathentry kind="lib" path="Libraries/lucene-regex-3.0.3.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-cypher-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-graph-algo-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-graph-matching-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-jmx-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-kernel-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-lucene-index-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-shell-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-udc-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/server-api-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-backup-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-com-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/neo4j-management-1.7.1.jar"/>
<classpathentry kind="lib" path="Libraries/org.apache.servicemix.bundles.netty-3.2.5.Final_1.jar"/>
<classpathentry kind="lib" path="Libraries/slf4j-api-1.6.1.jar"/>
<classpathentry kind="lib" path="Libraries/zookeeper-3.3.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 7 additions & 0 deletions Frameworks/EOAdaptors/JavaNeo4JAdaptor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target
bin
build
doc
*.xcodeproj
*.pbxproj
ant.*
23 changes: 23 additions & 0 deletions Frameworks/EOAdaptors/JavaNeo4JAdaptor/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JavaNeo4JAdaptor</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.objectstyle.wolips.incrementalbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.objectstyle.wolips.incrementalframeworknature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//Components=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Wed Jun 13 13:12:20 CEST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
34 changes: 34 additions & 0 deletions Frameworks/EOAdaptors/JavaNeo4JAdaptor/Resources/Properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
log4j.logger.er.neo4jadaptor.database.pool=INFO


# one of values: embedded-read-only | embedded-writable | highly-available
neo4j.pool.database.type=embedded-writable

# Neo4J database configuration
neo4j.pool.database.config={cache_type=weak; use_memory_mapped_buffers=true; dump_configuration=true;}

# If set to true then will fetch all nodes/relationships and try to load their properties into memory.
# Defaults to false.
neo4j.pool.doWarmUp=false







###########################
# Neo4J High Availability #
###########################

# Neo4J HA feature is available in enterprise version and requires a different license, however
# this framework should still be able to support HA if one has appropriate license, therefore
# we construct HA database using reflection, as otherwise neo4j-ha jar file would need to be
# included. Here we specify HA database class name. This value is valid for Neo4J version 1.7.
neo4j.pool.database.highly-available.class=org.neo4j.kernel.HighlyAvailableGraphDatabase

# Name of a property in database config dictionary, that contains server_id value
neo4j.pool.database.highly-available.server-id-config-key=ha.server_id

# This is only HA config proposal
# neo4j.pool.database.config={ha.server_id=1; ha.server=localhost:6001; ha.coordinators=localhost:2181; ha.pull_interval=30; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package er.neo4jadaptor;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;

import com.webobjects.eoaccess.EOAdaptor;
import com.webobjects.eoaccess.EOAdaptorContext;
import com.webobjects.eoaccess.EOModel;
import com.webobjects.eoaccess.EOSQLExpressionFactory;
import com.webobjects.eoaccess.EOSchemaGeneration;
import com.webobjects.eoaccess.synchronization.EOSchemaSynchronizationFactory;
import com.webobjects.foundation.NSDictionary;

import er.neo4jadaptor.database.pool.DatabasePool;

@SuppressWarnings("deprecation")
public class Neo4JAdaptor extends EOAdaptor {
private static final String CONFIG_PATH_KEY = "URL";

private GraphDatabaseService db;

static {
// Neo4JDelegate.init();
}

public static void init() {
// trigger static initializer
}

public Neo4JAdaptor(String name) {
super(name);
}

@Override
public void assertConnectionDictionaryIsValid() {
}

@Override
public void setConnectionDictionary(NSDictionary<String, Object> dictionary) {
super.setConnectionDictionary(dictionary);

String databasePath = (String) dictionary.objectForKey(CONFIG_PATH_KEY);

if (databasePath == null) {
throw new IllegalArgumentException("No \"" + CONFIG_PATH_KEY + "\" value given");
}

this.db = DatabasePool.instance.get(databasePath);
}

@Override
public EOSQLExpressionFactory expressionFactory() {
return null;
}

@Override
public boolean isValidQualifierType(String typeName, EOModel model) {
return true;
}

@Override
public EOSchemaSynchronizationFactory schemaSynchronizationFactory() {
return null;
}

@Override
public Class<?> defaultExpressionClass() {
throw new UnsupportedOperationException();
}



@Override
public EOAdaptorContext createAdaptorContext() {
return new Neo4JContext(this);
}

@Override
public EOSchemaGeneration synchronizationFactory() {
throw new UnsupportedOperationException();
}

public GraphDatabaseService getDatabase() {
return db;
}

public Number nextValFromSequenceNamed(String sequenceName) {
Node node = db.getReferenceNode();
Transaction tx = db.beginTx();

try {
int val = (Integer) node.getProperty(sequenceName, 0);

node.setProperty(sequenceName, val+1);
tx.success();

return val;
} finally {
tx.finish();
}
}
}
Loading

0 comments on commit c3df2b2

Please sign in to comment.