PageRenderTime 231ms CodeModel.GetById 90ms app.highlight 1ms RepoModel.GetById 120ms app.codeStats 0ms

/src/org/fraught/neo4j/neo4j.cfc

http://github.com/bpanulla/cf_neo4j
ColdFusion CFScript | 68 lines | 44 code | 24 blank | 0 comment | 0 complexity | 9d0600f82e1fc4c71f91167c94ac8511 MD5 | raw file
 1<cfcomponent output="false" displayname="Neo4J Graph Database Fa´┐Żade" hint="Provides simplified access to a Neo4j Graph Database to ColdFusion applications">
 2
 3
 4	<!--- Private properties --->
 5	<cfset variables.graphDb = CreateObject('java',"org.neo4j.kernel.EmbeddedGraphDatabase") />
 6	<cfset variables.relationshipTemplate = CreateObject("java", "org.neo4j.graphdb.DynamicRelationshipType")>
 7	
 8	<!--- Public methods --->
 9	<cffunction name="isInitialized" access="public" output="false" returntype="Boolean" hint="Tell if graph database connection has been initialized.">
10	
11		<cfset var status = true />
12		<cfset var pathTest = "" />
13
14		<cftry>
15			<cfset pathTest = getPath() />
16
17			<cfcatch type="any">
18				<cfset status = false />
19			</cfcatch>	
20		</cftry>
21		
22		<cfreturn status />	
23	</cffunction>
24
25
26	<cffunction name="initialize" access="public" output="false" returntype="Any">
27		<cfargument name="path" type="string" required="false" />
28	
29		<cfset var status = true />
30
31		<cftry>
32			<cfset variables.graphDb.init(arguments.path) />
33
34			<cfcatch type="any">
35				<cfset status = false />
36			</cfcatch>	
37		</cftry>
38		
39		<cfreturn this />
40	</cffunction>
41
42
43	<cffunction name="getPath" access="public" output="false" returntype="string">
44		<cfreturn graphDb.getStoreDir() />
45	</cffunction>
46	
47	
48	<cffunction name="createNode" access="public" output="false" returntype="any">
49		<cfreturn graphDb.createNode() />
50	</cffunction>
51
52	<cffunction name="beginTx" access="public" output="false" returntype="any">
53		<cfreturn graphDb.beginTx() />
54	</cffunction>
55
56	<cffunction name="getRelationship" access="public" output="false" returntype="any">
57		<cfargument name="relName" type="string" required="true">
58		
59		<cfreturn variables.relationshipTemplate.withName( arguments.relName ) />
60	</cffunction>
61	
62	<cffunction name="shutdown" access="public" output="false" returntype="any">		
63		<cfreturn graphDb.shutdown() />
64	</cffunction>
65	
66
67
68</cfcomponent>