@@ -134,13 +134,15 @@ Note: Individual values are serialized if they are not already.
134
134
If the additional properties is provided, the additional
135
135
properties will be added in verbatim when serializing.
136
136
137
+ Returns: `::String`
138
+
137
139
Related
138
140
139
141
_Neo4jTo???
140
142
"""
141
- function _structToNeo4jProps (inst:: Union{User, Robot, Session, PVND, N, APPE, ABDE} ,
142
- addProps:: Dict{String, String } = Dict {String, String} ();
143
- cypherNodeName:: String = " subnode" ):: String where
143
+ function _structToNeo4jProps (inst:: Union{<: User, <: Robot, <: Session, PVND, N, APPE, ABDE} ,
144
+ addProps:: Dict{<:AbstractString, <:AbstractString } = Dict {String, String} ();
145
+ cypherNodeName:: String = " subnode" ) where
144
146
{N <: DFGNode , APPE <: AbstractPointParametricEst , ABDE <: AbstractDataEntry , PVND <: PackedVariableNodeData }
145
147
props = Dict {String, String} ()
146
148
io = IOBuffer ()
@@ -156,7 +158,7 @@ function _structToNeo4jProps(inst::Union{User, Robot, Session, PVND, N, APPE, AB
156
158
val = " \" $(string (field)) \" "
157
159
end
158
160
# TODO : Switch this to decorator pattern
159
- if typeof (inst) <: DFGNode
161
+ if inst isa DFGNode # typeof(inst) <: DFGNode
160
162
# Variables
161
163
fieldname == :solverDataDict && continue
162
164
fieldname == :ppeDict && continue
@@ -178,23 +180,12 @@ function _structToNeo4jProps(inst::Union{User, Robot, Session, PVND, N, APPE, AB
178
180
# TODO : Consolidate with packFactor in Serialization.jl - https://github.com/JuliaRobotics/DistributedFactorGraphs.jl/issues/525
179
181
if fieldname == :solverData
180
182
fnctype = getSolverData (inst). fnc. usrfnc!
181
- try
182
- packtype = convertPackedType (fnctype)
183
- packed = convert (PackedFunctionNodeData{packtype}, getSolverData (inst))
184
- packedJson = JSON2. write (packed)
185
- val = " \" $(replace (packedJson, " \" " => " \\\" " )) \" " # Escape slashes too
186
- fieldname = :data # Keeping with FileDFG format
187
- catch ex
188
- io = IOBuffer ()
189
- showerror (io, ex, catch_backtrace ())
190
- err = String (take! (io))
191
- msg = " Error while packing '$(inst. label) ' as '$fnctype ', please check the unpacking/packing converters for this factor - \r\n $err "
192
- error (msg)
193
- end
183
+ val = _packSolverData ( inst, fnctype; replaceBackslashes= true )
184
+ fieldname = :data # Keeping with FileDFG format
194
185
end
195
186
end
196
187
# Fallback, default to JSON2
197
- if val == nothing
188
+ if val === nothing
198
189
val = JSON2. write (field)
199
190
end
200
191
write (io, " $cypherNodeName .$fieldname =$val ," )
0 commit comments