Skip to content

Commit 97dd808

Browse files
committed
Always create the sentinel nodes
1 parent 4865411 commit 97dd808

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
3232
getPackedTypeFunc,
3333
decodePackedTypeFunc,
3434
rebuildFactorMetadata!;
35-
solverParams::T=NoSolverParams()) where T <: AbstractParams
35+
solverParams::T=NoSolverParams(),
36+
createSessionNodes::Bool=true) where T <: AbstractParams
3637
graph = Neo4j.getgraph(neo4jConnection)
3738
neo4jInstance = Neo4jInstance(neo4jConnection, graph)
38-
return CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, Symbol[], solverParams)
39+
dfg = CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, Symbol[], solverParams)
40+
# Create the session if it doesn't already exist
41+
createSessionNodes && createDfgSessionIfNotExist(dfg)
42+
return dfg
3943
end
4044
"""
4145
$(SIGNATURES)
@@ -53,9 +57,10 @@ function CloudGraphsDFG{T}(host::String,
5357
getPackedTypeFunc,
5458
decodePackedTypeFunc,
5559
rebuildFactorMetadata!;
56-
solverParams::T=NoSolverParams()) where T <: AbstractParams
60+
solverParams::T=NoSolverParams(),
61+
createSessionNodes::Bool=true) where T <: AbstractParams
5762
neo4jConnection = Neo4j.Connection(host, port=port, user=dbUser, password=dbPassword);
58-
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, solverParams=solverParams)
63+
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, solverParams=solverParams, createSessionNodes=createSessionNodes)
5964
end
6065

6166

src/CloudGraphsDFG/services/CGStructure.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function createDfgSessionIfNotExist(dfg::CloudGraphsDFG)::Session
114114
strip(dfg.sessionId) == "" && error("Session ID is not populated in DFG.")
115115
user = User(Symbol(dfg.userId), dfg.userId, "Description for $(dfg.userId)", Dict{Symbol, String}())
116116
robot = Robot(Symbol(dfg.robotId), Symbol(dfg.userId), dfg.robotId, "Description for $(dfg.userId):$(dfg.robotId)", Dict{Symbol, String}())
117-
session = Session(Symbol(dfg.sessionId), Symbol(dfg.robotId), Symbol(dfg.userId), dfg.sessionId, "Description for $(dfg.userId):$(dfg.robotId):$(dfg.sessionId)", Dict{Symbol, String}())
117+
session = Session(Symbol(dfg.sessionId), Symbol(dfg.robotId), Symbol(dfg.userId), dfg.sessionId, dfg.description, Dict{Symbol, String}())
118118

119119
_getNodeCount(dfg.neo4jInstance, [dfg.userId, "USER"]) == 0 && createUser(dfg, user)
120120
_getNodeCount(dfg.neo4jInstance, [dfg.userId, dfg.robotId, "ROBOT"]) == 0 && createRobot(dfg, robot)

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function _getDuplicatedEmptyDFG(dfg::CloudGraphsDFG)::CloudGraphsDFG
99
while true #do..while loop
1010
count += 1
1111
sessionId = dfg.sessionId*"_$count"
12-
length(_getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId):$(sessionId))")) == 0 && break
12+
_getNodeCount(dfg.neo4jInstance, [dfg.userId, dfg.robotId, sessionId]) == 0 && break
1313
end
1414
@debug "Unique+empty copy session name: $sessionId"
1515
return CloudGraphsDFG{typeof(dfg.solverParams)}(

0 commit comments

Comments
 (0)