@@ -17,6 +17,7 @@ function _getDuplicatedEmptyDFG(dfg::CloudGraphsDFG)::CloudGraphsDFG
17
17
dfg. userId,
18
18
dfg. robotId,
19
19
sessionId,
20
+ dfg. description,
20
21
dfg. encodePackedTypeFunc,
21
22
dfg. getPackedTypeFunc,
22
23
dfg. decodePackedTypeFunc,
@@ -32,11 +33,13 @@ function getDescription(dfg::CloudGraphsDFG)
32
33
" description" )
33
34
end
34
35
function setDescription! (dfg:: CloudGraphsDFG , description:: String )
35
- _setNodeProperty (
36
- dfg. neo4jInstance,
37
- [dfg. sessionId, dfg. robotId, dfg. userId, " SESSION" ],
38
- " description" ,
39
- description)
36
+ count = _setNodeProperty (dfg. neo4jInstance,
37
+ [dfg. sessionId, dfg. robotId, dfg. userId, " SESSION" ],
38
+ " description" ,
39
+ description)
40
+ @assert (count == 1 )
41
+ dfg. description = description
42
+ return getDescription (dfg)
40
43
end
41
44
42
45
function getSerializationModule (dfg:: CloudGraphsDFG ):: Module where G <: AbstractDFG
@@ -53,43 +56,89 @@ function getUserData(dfg::CloudGraphsDFG)::Dict{Symbol, String}
53
56
propVal = _getNodeProperty (dfg. neo4jInstance, _getLabelsForType (dfg, User), " data" )
54
57
return JSON2. read (String (base64decode (propVal)), Dict{Symbol, String})
55
58
end
56
- function setUserData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Bool
59
+ function setUserData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Dict{Symbol, String}
57
60
count = _setNodeProperty (dfg. neo4jInstance, [dfg. userId, " USER" ], " data" , base64encode (JSON2. write (data)))
58
- return count == 1
61
+ @assert (count == 1 )
62
+ return getUserData (dfg)
59
63
end
64
+
60
65
function getRobotData (dfg:: CloudGraphsDFG ):: Dict{Symbol, String}
61
66
propVal = _getNodeProperty (dfg. neo4jInstance, [dfg. userId, dfg. robotId, " ROBOT" ], " data" )
62
67
return JSON2. read (String (base64decode (propVal)), Dict{Symbol, String})
63
68
end
64
- function setRobotData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Bool
69
+ function setRobotData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Dict{Symbol, String}
65
70
count = _setNodeProperty (dfg. neo4jInstance, [dfg. userId, dfg. robotId, " ROBOT" ], " data" , base64encode (JSON2. write (data)))
66
- return count == 1
71
+ @assert (count == 1 )
72
+ return getRobotData (dfg)
67
73
end
74
+
68
75
function getSessionData (dfg:: CloudGraphsDFG ):: Dict{Symbol, String}
69
76
propVal = _getNodeProperty (dfg. neo4jInstance, [dfg. userId, dfg. robotId, dfg. sessionId, " SESSION" ], " data" )
70
77
return JSON2. read (String (base64decode (propVal)), Dict{Symbol, String})
71
78
end
72
- function setSessionData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Bool
79
+ function setSessionData! (dfg:: CloudGraphsDFG , data:: Dict{Symbol, String} ):: Dict{Symbol, String}
73
80
count = _setNodeProperty (dfg. neo4jInstance, [dfg. userId, dfg. robotId, dfg. sessionId, " SESSION" ], " data" , base64encode (JSON2. write (data)))
74
- return count == 1
81
+ @assert (count == 1 )
82
+ return getSessionData (dfg)
75
83
end
76
84
77
85
# New API
78
- getUserData (dfg:: CloudGraphsDFG , key:: Symbol ):: String = error (" Not supported yet" )
79
- getRobotData (dfg:: CloudGraphsDFG , key:: Symbol ):: String = error (" Not supported yet" )
80
- getSessionData (dfg:: CloudGraphsDFG , key:: Symbol ):: String = error (" Not supported yet" )
86
+ getUserData (dfg:: CloudGraphsDFG , key:: Symbol ) = getUserData (dfg:: CloudGraphsDFG )[key]
87
+ getRobotData (dfg:: CloudGraphsDFG , key:: Symbol ):: String = getRobotData (dfg:: CloudGraphsDFG )[key]
88
+ getSessionData (dfg:: CloudGraphsDFG , key:: Symbol ):: String = getSessionData (dfg:: CloudGraphsDFG )[key]
89
+
90
+ function updateUserData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} )
91
+ data = getUserData (dfg:: CloudGraphsDFG )
92
+ push! (data, pair)
93
+ setUserData! (dfg, data)
94
+ end
95
+
96
+ function updateRobotData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} )
97
+ data = getRobotData (dfg:: CloudGraphsDFG )
98
+ push! (data, pair)
99
+ setRobotData! (dfg, data)
100
+ end
101
+
102
+ function updateSessionData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} )
103
+ data = getSessionData (dfg:: CloudGraphsDFG )
104
+ push! (data, pair)
105
+ setSessionData! (dfg, data)
106
+ end
107
+
108
+ function deleteUserData! (dfg:: CloudGraphsDFG , key:: Symbol )
109
+ data = getUserData (dfg:: CloudGraphsDFG )
110
+ delval = pop! (data, key)
111
+ setUserData! (dfg, data)
112
+ return delval
113
+ end
114
+
115
+ function deleteRobotData! (dfg:: CloudGraphsDFG , key:: Symbol )
116
+ data = getRobotData (dfg:: CloudGraphsDFG )
117
+ delval = pop! (data, key)
118
+ setRobotData! (dfg, data)
119
+ return delval
120
+ end
81
121
82
- updateUserData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} ) = error (" Not supported yet" )
83
- updateRobotData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} ) = error (" Not supported yet" )
84
- updateSessionData! (dfg:: CloudGraphsDFG , pair:: Pair{Symbol,String} ) = error (" Not supported yet" )
122
+ function deleteSessionData! (dfg:: CloudGraphsDFG , key:: Symbol )
123
+ data = getSessionData (dfg:: CloudGraphsDFG )
124
+ delval = pop! (data, key)
125
+ setSessionData! (dfg, data)
126
+ return delval
127
+ end
128
+
129
+
130
+ function emptyUserData! (dfg:: CloudGraphsDFG )
131
+ return setUserData! (dfg, Dict {Symbol, String} ())
132
+ end
85
133
86
- deleteUserData! (dfg:: CloudGraphsDFG , key:: Symbol ) = error (" Not supported yet" )
87
- deleteRobotData! (dfg:: CloudGraphsDFG , key:: Symbol ) = error (" Not supported yet" )
88
- deleteSessionData! (dfg:: CloudGraphsDFG , key:: Symbol ) = error (" Not supported yet" )
134
+ function emptyRobotData! (dfg:: CloudGraphsDFG )
135
+ return setRobotData! (dfg, Dict {Symbol, String} ())
136
+ end
137
+
138
+ function emptySessionData! (dfg:: CloudGraphsDFG )
139
+ return setSessionData! (dfg, Dict {Symbol, String} ())
140
+ end
89
141
90
- emptyUserData! (dfg:: CloudGraphsDFG ) = error (" Not supported yet" )
91
- emptyRobotData! (dfg:: CloudGraphsDFG ) = error (" Not supported yet" )
92
- emptySessionData! (dfg:: CloudGraphsDFG ) = error (" Not supported yet" )
93
142
94
143
# #==============================================================================
95
144
# # CRUD Interfaces
@@ -132,17 +181,15 @@ function addVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)::DFGVariable
132
181
return variable
133
182
end
134
183
135
- function addFactor! (dfg:: CloudGraphsDFG , factor:: DFGFactor )
136
- addFactor! (dfg, factor. _variableOrderSymbols, factor)
137
- end
138
184
139
- function addFactor! (dfg:: CloudGraphsDFG , variables :: Vector{<:DFGVariable} , factor:: DFGFactor ):: DFGFactor
185
+ function addFactor! (dfg:: CloudGraphsDFG , factor:: DFGFactor ):: DFGFactor
140
186
if exists (dfg, factor)
141
187
error (" Factor '$(factor. label) ' already exists in the factor graph" )
142
188
end
143
189
144
- # Update the variable ordering
145
- factor. _variableOrderSymbols = map (v-> v. label, variables)
190
+ variableIds = factor. _variableOrderSymbols
191
+ variables = map (vId -> getVariable (dfg, vId), variableIds)
192
+
146
193
147
194
# Construct the properties to save
148
195
props = packFactor (dfg, factor)
@@ -163,16 +210,11 @@ function addFactor!(dfg::CloudGraphsDFG, variables::Vector{<:DFGVariable}, facto
163
210
return factor
164
211
end
165
212
166
- function addFactor! (dfg:: CloudGraphsDFG , variableIds:: Vector{Symbol} , factor:: DFGFactor ):: DFGFactor
167
- variables = map (vId -> getVariable (dfg, vId), variableIds)
168
- return addFactor! (dfg, variables, factor)
169
- end
170
-
171
213
function getVariable (dfg:: CloudGraphsDFG , label:: Union{Symbol, String} ):: DFGVariable
172
214
if typeof (label) == String
173
215
label = Symbol (label)
174
216
end
175
- nodeId = _tryGetNeoNodeIdFromNodeLabel (dfg. neo4jInstance, dfg. userId, dfg. robotId, dfg. sessionId, label)
217
+ nodeId = _tryGetNeoNodeIdFromNodeLabel (dfg. neo4jInstance, dfg. userId, dfg. robotId, dfg. sessionId, label, nodeType = " VARIABLE " )
176
218
if nodeId == nothing
177
219
error (" Unable to retrieve the ID for variable '$label '. Please check your connection to the database and that the variable exists." )
178
220
end
@@ -191,7 +233,7 @@ function getFactor(dfg::CloudGraphsDFG, label::Union{Symbol, String})::DFGFactor
191
233
if typeof (label) == String
192
234
label = Symbol (label)
193
235
end
194
- nodeId = _tryGetNeoNodeIdFromNodeLabel (dfg. neo4jInstance, dfg. userId, dfg. robotId, dfg. sessionId, label)
236
+ nodeId = _tryGetNeoNodeIdFromNodeLabel (dfg. neo4jInstance, dfg. userId, dfg. robotId, dfg. sessionId, label, nodeType = " FACTOR " )
195
237
if nodeId == nothing
196
238
error (" Unable to retrieve the ID for factor '$label '. Please check your connection to the database and that the factor exists." )
197
239
end
0 commit comments