PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/src/hello_world.cfm

http://github.com/bpanulla/cf_neo4j
ColdFusion | 39 lines | 28 code | 11 blank | 0 comment | 0 complexity | 2ab373211e85f489168ae2b43de57693 MD5 | raw file
 1<cfset dbroot = "/tmp/neo4jtest/" />
 2
 3<cfset graphDb = createObject('java',"org.neo4j.kernel.EmbeddedGraphDatabase") />
 4<cfset graphDb.init(dbroot & "var/graphdb") />
 5
 6<cfset relationship = CreateObject("java", "org.neo4j.graphdb.DynamicRelationshipType") />
 7
 8<cftry>
 9	<cfset tx = graphDb.beginTx() />
10	
11	<cfscript>
12		MyRelationshipTypes = structNew();
13		MyRelationshipTypes.KNOWS = relationship.withName( "KNOWS" );
14		
15		firstNode = graphDb.createNode();
16		secondNode = graphDb.createNode();
17		relationship = firstNode.createRelationshipTo( secondNode, MyRelationshipTypes.KNOWS );
18		 
19		firstNode.setProperty( "message", "Hello, " );
20		secondNode.setProperty( "message", "world!" );
21		relationship.setProperty( "message", "brave Neo4j " );
22
23		WriteOutput( firstNode.getProperty( "message" ) );
24		WriteOutput( relationship.getProperty( "message" ) );
25		WriteOutput( secondNode.getProperty( "message" ) );
26
27		tx.success();
28	</cfscript>
29	
30
31	<cfset tx.finish() />
32	<cfcatch type="any">
33		<cfset graphDb.shutdown() />
34		<cfdump var="#cfcatch#">
35	</cfcatch>
36</cftry>
37
38<cfset graphDb.shutdown() />
39Done.