Skip to content

Commit 5158c8f

Browse files
committed
rename and test Neo4jDFG
1 parent cc06c20 commit 5158c8f

18 files changed

+155
-152
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NOTICE: this license will be relaxed to be much more permissive soon.
55
The source code in this repository is separated into two parts
66
that are licensed separately. The Neo4jDFG library/driver
77
is licensed separately. For more details see:
8-
https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/blob/develop/src/CloudGraphsDFG/LICENSE
8+
https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/blob/develop/src/Neo4jDFG/LICENSE
99

1010
DistributedFactorGraphs.jl, is not licensed for hosted, webservice or cloud
1111
solutions (public or private). Please contact NavAbility via email at

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ makedocs(
1818
],
1919
# "DistributedFactorGraph API's" => [
2020
# "LightDFGs" => "apis/LightGraphs.md",
21-
# "CloudGraphsDFGs" => "apis/CloudGraphs.md",
21+
# "Neo4jDFGs" => "apis/CloudGraphs.md",
2222
# ],
2323
"Function Reference" => "func_ref.md"
2424
]

src/Neo4jDFG/Neo4jDFG.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module CloudGraphsDFGs
1+
module Neo4jDFGs
22

33
using ...DistributedFactorGraphs
44

@@ -105,13 +105,13 @@ using SparseArrays
105105
using UUIDs
106106

107107
# Entities
108-
include("entities/CloudGraphsDFG.jl")
108+
include("entities/Neo4jDFG.jl")
109109
include("entities/CGStructure.jl")
110110

111111
# Services
112112
include("services/CommonFunctions.jl")
113113
include("services/CGStructure.jl")
114-
include("services/CloudGraphsDFG.jl")
114+
include("services/Neo4jDFG.jl")
115115

116116
# Exports
117117
export Neo4jInstance, Neo4jDFG
@@ -127,4 +127,7 @@ export getSession, getRobot, getUser
127127
export updateSession, updateRobot, updateUser
128128
export lsSessions, lsRobots, lsUsers
129129

130+
const CloudGraphsDFG = Neo4jDFG
131+
# const CloudGraphsDFG{T} = Neo4jDFG{T}
132+
130133
end

src/Neo4jDFG/entities/Neo4jDFG.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mutable struct Neo4jInstance
55
graph::Neo4j.Graph
66
end
77

8-
mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG{T}
8+
mutable struct Neo4jDFG{T <: AbstractParams} <: AbstractDFG{T}
99
neo4jInstance::Neo4jInstance
1010
userId::String
1111
robotId::String
@@ -16,7 +16,7 @@ mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG{T}
1616
blobStores::Dict{Symbol, AbstractBlobStore}
1717

1818
# inner constructor for all constructors in common
19-
function CloudGraphsDFG{T}(neo4jInstance::Neo4jInstance,
19+
function Neo4jDFG{T}(neo4jInstance::Neo4jInstance,
2020
userId::String,
2121
robotId::String,
2222
sessionId::String,
@@ -55,7 +55,7 @@ end
5555
$(SIGNATURES)
5656
Create a new CloudGraphs-based DFG factor graph using a Neo4j.Connection or by specifying the Neo4j connection information
5757
"""
58-
function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
58+
function Neo4jDFG{T}(neo4jConnection::Neo4j.Connection,
5959
userId::String,
6060
robotId::String,
6161
sessionId::String,
@@ -66,11 +66,11 @@ function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
6666
graph = Neo4j.getgraph(neo4jConnection)
6767
neo4jInstance = Neo4jInstance(neo4jConnection, graph)
6868

69-
return CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, description, Symbol[], solverParams; kwargs...)
69+
return Neo4jDFG{T}(neo4jInstance, userId, robotId, sessionId, description, Symbol[], solverParams; kwargs...)
7070

7171
end
7272

73-
function CloudGraphsDFG{T}(host::String,
73+
function Neo4jDFG{T}(host::String,
7474
port::Int,
7575
dbUser::String,
7676
dbPassword::String,
@@ -80,22 +80,22 @@ function CloudGraphsDFG{T}(host::String,
8080
description::String;
8181
kwargs...) where T <: AbstractParams
8282
neo4jConnection = Neo4j.Connection(host, port=port, user=dbUser, password=dbPassword)
83-
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, description; kwargs...)
83+
return Neo4jDFG{T}(neo4jConnection, userId, robotId, sessionId, description; kwargs...)
8484
end
8585

8686
# construct using the default settings for localhost
87-
function CloudGraphsDFG(; hostname="localhost",
87+
function Neo4jDFG(; hostname="localhost",
8888
port=7474,
8989
username="neo4j",
9090
password="test",
9191
userId::String="DefaultUser",
9292
robotId::String="DefaultRobot",
9393
sessionId::String="Session_$(string(uuid4())[1:6])", #TODO randstring(['a':'z';'A':'Z'],1) ipv Session
94-
description::String="CloudGraphsDFG implementation",
94+
description::String="Neo4jDFG implementation",
9595
solverParams::T=NoSolverParams(),
9696
kwargs...) where T <: AbstractParams
9797

98-
return CloudGraphsDFG{T}(hostname,
98+
return Neo4jDFG{T}(hostname,
9999
port,
100100
username,
101101
password,
@@ -107,7 +107,7 @@ function CloudGraphsDFG(; hostname="localhost",
107107
kwargs...)
108108
end
109109

110-
function CloudGraphsDFG(description::String,
110+
function Neo4jDFG(description::String,
111111
userId::String,
112112
robotId::String,
113113
sessionId::String,
@@ -120,7 +120,7 @@ function CloudGraphsDFG(description::String,
120120
dbUser::String = "neo4j",
121121
dbPassword::String = "test")
122122

123-
return CloudGraphsDFG{typeof(solverParams)}(host,
123+
return Neo4jDFG{typeof(solverParams)}(host,
124124
port,
125125
dbUser,
126126
dbPassword,
@@ -136,8 +136,8 @@ function CloudGraphsDFG(description::String,
136136

137137
end
138138

139-
function show(io::IO, ::MIME"text/plain", c::CloudGraphsDFG)
140-
println(io, "CloudGraphsDFG:")
139+
function show(io::IO, ::MIME"text/plain", c::Neo4jDFG)
140+
println(io, "Neo4jDFG:")
141141
println(io, " - Neo4J instance: $(c.neo4jInstance.connection.host)")
142142
println(io, " - Session: $(c.userId):$(c.robotId):$(c.sessionId)")
143143
println(io, " - Description: ", c.description)

src/Neo4jDFG/services/CGStructure.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function _convertDictToUser(dict::Dict{String, Any})::User
5454
return user
5555
end
5656

57-
function createUser(dfg::CloudGraphsDFG, user::User)::User
57+
function createUser(dfg::Neo4jDFG, user::User)::User
5858
Symbol(dfg.userId) != user.id && error("DFG user ID must match user's ID")
5959
!isValidLabel(user) && error("Node cannot have an ID '$(user.id)'.")
6060

@@ -64,7 +64,7 @@ function createUser(dfg::CloudGraphsDFG, user::User)::User
6464
return user
6565
end
6666

67-
function createRobot(dfg::CloudGraphsDFG, robot::Robot)::Robot
67+
function createRobot(dfg::Neo4jDFG, robot::Robot)::Robot
6868
Symbol(dfg.robotId) != robot.id && error("DFG robot ID must match robot's ID")
6969
Symbol(dfg.userId) != robot.userId && error("DFG user ID must match robot's user ID")
7070
!isValidLabel(robot) && error("Node cannot have an ID '$(robot.id)'.")
@@ -84,7 +84,7 @@ function createRobot(dfg::CloudGraphsDFG, robot::Robot)::Robot
8484
return robot
8585
end
8686

87-
function createSession(dfg::CloudGraphsDFG, session::Session)::Session
87+
function createSession(dfg::Neo4jDFG, session::Session)::Session
8888
Symbol(dfg.robotId) != session.robotId && error("DFG robot ID must match session's robot ID")
8989
Symbol(dfg.userId) != session.userId && error("DFG user ID must match session's->robot's->user ID")
9090
!isValidLabel(session) && error("Node cannot have an ID '$(session.id)'.")
@@ -108,7 +108,7 @@ end
108108
$(SIGNATURES)
109109
Shortcut method to create the user, robot, and session if it doesn't already exist.
110110
"""
111-
function createDfgSessionIfNotExist(dfg::CloudGraphsDFG)::Session
111+
function createDfgSessionIfNotExist(dfg::Neo4jDFG)::Session
112112
strip(dfg.userId) == "" && error("User ID is not populated in DFG.")
113113
strip(dfg.robotId) == "" && error("Robot ID is not populated in DFG.")
114114
strip(dfg.sessionId) == "" && error("Session ID is not populated in DFG.")
@@ -130,7 +130,7 @@ $(SIGNATURES)
130130
List all sessions for the specified DFG's robot and user.
131131
Returns nothing if it isn't found.
132132
"""
133-
function lsSessions(dfg::CloudGraphsDFG)::Vector{Session}
133+
function lsSessions(dfg::Neo4jDFG)::Vector{Session}
134134
sessionNodes = _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:SESSION:$(dfg.robotId):$(dfg.userId))")
135135
return map(s -> _convertDictToSession(Neo4j.getnodeproperties(s)), sessionNodes)
136136
end
@@ -140,7 +140,7 @@ $(SIGNATURES)
140140
List all robots for the specified DFG's user.
141141
Returns nothing if it isn't found.
142142
"""
143-
function lsRobots(dfg::CloudGraphsDFG)::Vector{Robot}
143+
function lsRobots(dfg::Neo4jDFG)::Vector{Robot}
144144
robotNodes = _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:ROBOT:$(dfg.userId))")
145145
return map(s -> _convertDictToRobot(Neo4j.getnodeproperties(s)), robotNodes)
146146
end
@@ -150,7 +150,7 @@ $(SIGNATURES)
150150
List all users.
151151
Returns nothing if it isn't found.
152152
"""
153-
function lsUsers(dfg::CloudGraphsDFG)::Vector{User}
153+
function lsUsers(dfg::Neo4jDFG)::Vector{User}
154154
userNodes = _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:USER)")
155155
return map(s -> _convertDictToUser(Neo4j.getnodeproperties(s)), userNodes)
156156
end
@@ -160,7 +160,7 @@ $(SIGNATURES)
160160
Get a session specified by userId:robotId:sessionId.
161161
Returns nothing if it isn't found.
162162
"""
163-
function getSession(dfg::CloudGraphsDFG, userId::Symbol, robotId::Symbol, sessionId::Symbol)::Union{Session, Nothing}
163+
function getSession(dfg::Neo4jDFG, userId::Symbol, robotId::Symbol, sessionId::Symbol)::Union{Session, Nothing}
164164
!isValidLabel(userId) && error("Can't retrieve session with user ID '$(userId)'.")
165165
!isValidLabel(robotId) && error("Can't retrieve session with robot ID '$(robotId)'.")
166166
!isValidLabel(sessionId) && error("Can't retrieve session with session ID '$(sessionId)'.")
@@ -175,7 +175,7 @@ $(SIGNATURES)
175175
Get the session specified by the DFG object.
176176
Returns nothing if it isn't found.
177177
"""
178-
function getSession(dfg::CloudGraphsDFG)::Union{Nothing, Session}
178+
function getSession(dfg::Neo4jDFG)::Union{Nothing, Session}
179179
return getSession(dfg, Symbol(dfg.userId), Symbol(dfg.robotId), Symbol(dfg.sessionId))
180180
end
181181

@@ -184,7 +184,7 @@ $(SIGNATURES)
184184
Get a robot specified by userId:robotId.
185185
Returns nothing if it isn't found.
186186
"""
187-
function getRobot(dfg::CloudGraphsDFG, userId::Symbol, robotId::Symbol)::Union{Robot, Nothing}
187+
function getRobot(dfg::Neo4jDFG, userId::Symbol, robotId::Symbol)::Union{Robot, Nothing}
188188
!isValidLabel(userId) && error("Can't retrieve robot with user ID '$(userId)'.")
189189
!isValidLabel(robotId) && error("Can't retrieve robot with robot ID '$(robotId)'.")
190190
robotNode = _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:ROBOT:$(robotId):$(userId))")
@@ -198,7 +198,7 @@ $(SIGNATURES)
198198
Get the robot specified by the DFG object.
199199
Returns nothing if it isn't found.
200200
"""
201-
function getRobot(dfg::CloudGraphsDFG)::Union{Nothing, Robot}
201+
function getRobot(dfg::Neo4jDFG)::Union{Nothing, Robot}
202202
return getRobot(dfg, Symbol(dfg.userId), Symbol(dfg.robotId))
203203
end
204204

@@ -207,7 +207,7 @@ $(SIGNATURES)
207207
Get a user specified by userId.
208208
Returns nothing if it isn't found.
209209
"""
210-
function getUser(dfg::CloudGraphsDFG, userId::Symbol)::Union{User, Nothing}
210+
function getUser(dfg::Neo4jDFG, userId::Symbol)::Union{User, Nothing}
211211
!isValidLabel(userId) && error("Can't retrieve user with user ID '$(userId)'.")
212212
userNode = _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:USER:$(userId))")
213213
length(userNode) == 0 && return nothing
@@ -220,7 +220,7 @@ $(SIGNATURES)
220220
Get the user specified by the DFG object.
221221
Returns nothing if it isn't found.
222222
"""
223-
function getUser(dfg::CloudGraphsDFG)::Union{Nothing, User}
223+
function getUser(dfg::Neo4jDFG)::Union{Nothing, User}
224224
return getUser(dfg, Symbol(dfg.userId))
225225
end
226226

@@ -229,7 +229,7 @@ end
229229
$(SIGNATURES)
230230
DANGER: Clears the whole session from the database.
231231
"""
232-
function clearSession!!(dfg::CloudGraphsDFG)::Nothing
232+
function clearSession!!(dfg::Neo4jDFG)::Nothing
233233
# Perform detach+deletion
234234
_queryNeo4j(dfg.neo4jInstance, "match (node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId)) detach delete node ")
235235

@@ -242,7 +242,7 @@ end
242242
$(SIGNATURES)
243243
DANGER: Clears the whole robot + sessions from the database.
244244
"""
245-
function clearRobot!!(dfg::CloudGraphsDFG)::Nothing
245+
function clearRobot!!(dfg::Neo4jDFG)::Nothing
246246
# Perform detach+deletion
247247
_queryNeo4j(dfg.neo4jInstance, "match (node:$(dfg.userId):$(dfg.robotId)) detach delete node ")
248248

@@ -255,7 +255,7 @@ end
255255
$(SIGNATURES)
256256
DANGER: Clears the whole user + robot + sessions from the database.
257257
"""
258-
function clearUser!!(dfg::CloudGraphsDFG)::Nothing
258+
function clearUser!!(dfg::Neo4jDFG)::Nothing
259259
# Perform detach+deletion
260260
_queryNeo4j(dfg.neo4jInstance, "match (node:$(dfg.userId)) detach delete node ")
261261

@@ -269,7 +269,7 @@ end
269269
DANGER: Copies and overwrites the destination session.
270270
If no destination specified then it creates a unique one.
271271
"""
272-
function copySession!(sourceDFG::CloudGraphsDFG, destDFG::Union{Nothing, CloudGraphsDFG})::CloudGraphsDFG
272+
function copySession!(sourceDFG::Neo4jDFG, destDFG::Union{Nothing, Neo4jDFG})::Neo4jDFG
273273
if destDFG == nothing
274274
destDFG = _getDuplicatedEmptyDFG(sourceDFG)
275275
end
@@ -280,4 +280,4 @@ end
280280
$(SIGNATURES)
281281
DANGER: Copies the source to a new unique destination.
282282
"""
283-
copySession!(sourceDFG::CloudGraphsDFG)::CloudGraphsDFG = copySession!(sourceDFG, nothing)
283+
copySession!(sourceDFG::Neo4jDFG)::Neo4jDFG = copySession!(sourceDFG, nothing)

src/Neo4jDFG/services/CommonFunctions.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ $(SIGNATURES)
209209
210210
Get the Neo4j labels for any node type.
211211
"""
212-
function _getLabelsForType(dfg::CloudGraphsDFG,
212+
function _getLabelsForType(dfg::Neo4jDFG,
213213
type::Type;
214214
parentKey::Union{Nothing, Symbol}=nothing)
215215
# Simple validation
@@ -241,7 +241,7 @@ $(SIGNATURES)
241241
242242
Get the Neo4j labels for any node instance.
243243
"""
244-
function _getLabelsForInst(dfg::CloudGraphsDFG,
244+
function _getLabelsForInst(dfg::Neo4jDFG,
245245
inst::Union{User, Robot, Session, VariableNodeData, N, APPE, ABDE};
246246
parentKey::Union{Nothing, Symbol}=nothing)::Vector{String} where
247247
{N <: DFGNode, APPE <: AbstractPointParametricEst, ABDE <: AbstractDataEntry}
@@ -256,7 +256,7 @@ end
256256

257257
## Common CRUD calls for subnode types (PPEs, VariableSolverData, BigData)
258258

259-
function _listVarSubnodesForType(dfg::CloudGraphsDFG, variablekey::Symbol, dfgType::Type, keyToReturn::String; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
259+
function _listVarSubnodesForType(dfg::Neo4jDFG, variablekey::Symbol, dfgType::Type, keyToReturn::String; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
260260
query = "match (subnode:$(join(_getLabelsForType(dfg, dfgType, parentKey=variablekey),':'))) return subnode.$keyToReturn"
261261
@debug "[Query] _listVarSubnodesForType query:\r\n$query"
262262
result = nothing
@@ -272,7 +272,7 @@ function _listVarSubnodesForType(dfg::CloudGraphsDFG, variablekey::Symbol, dfgTy
272272
return Symbol.(vals)
273273
end
274274

275-
function _getVarSubnodeProperties(dfg::CloudGraphsDFG, variablekey::Symbol, dfgType::Type, nodeKey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
275+
function _getVarSubnodeProperties(dfg::Neo4jDFG, variablekey::Symbol, dfgType::Type, nodeKey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
276276
query = "match (subnode:$(join(_getLabelsForType(dfg, dfgType, parentKey=variablekey),':')):$nodeKey) return properties(subnode)"
277277
@debug "[Query] _getVarSubnodeProperties query:\r\n$query"
278278
result = nothing
@@ -290,7 +290,7 @@ function _getVarSubnodeProperties(dfg::CloudGraphsDFG, variablekey::Symbol, dfgT
290290
end
291291

292292
function _matchmergeVariableSubnode!(
293-
dfg::CloudGraphsDFG,
293+
dfg::Neo4jDFG,
294294
variablekey::Symbol,
295295
nodeLabels::Vector{String},
296296
subnode::Union{APPE, ABDE, PVND},
@@ -321,7 +321,7 @@ function _matchmergeVariableSubnode!(
321321
end
322322

323323
function _deleteVarSubnode!(
324-
dfg::CloudGraphsDFG,
324+
dfg::Neo4jDFG,
325325
variablekey::Symbol,
326326
relationshipKey::Symbol,
327327
nodeLabels::Vector{String},

0 commit comments

Comments
 (0)