|
| 1 | +# Additional exports |
| 2 | +export copySession! |
| 3 | +# Please be careful with these |
| 4 | +# With great power comes great "Oh crap, I deleted everything..." |
| 5 | +export clearSession!!, clearRobot!!, clearUser!! |
| 6 | + |
| 7 | + |
| 8 | +""" |
| 9 | + $(SIGNATURES) |
| 10 | +DANGER: Clears the whole session from the database. |
| 11 | +""" |
| 12 | +function clearSession!!(dfg::CloudGraphsDFG)::Nothing |
| 13 | + # Perform detach+deletion |
| 14 | + _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId)) detach delete node ") |
| 15 | + |
| 16 | + # Clearing history |
| 17 | + dfg.addHistory = Symbol[] |
| 18 | + empty!(dfg.variableCache) |
| 19 | + empty!(dfg.factorCache) |
| 20 | + empty!(dfg.labelDict) |
| 21 | + return nothing |
| 22 | +end |
| 23 | + |
| 24 | +""" |
| 25 | + $(SIGNATURES) |
| 26 | +DANGER: Clears the whole robot + sessions from the database. |
| 27 | +""" |
| 28 | +function clearRobot!!(dfg::CloudGraphsDFG)::Nothing |
| 29 | + # Perform detach+deletion |
| 30 | + _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId)) detach delete node ") |
| 31 | + |
| 32 | + # Clearing history |
| 33 | + dfg.addHistory = Symbol[] |
| 34 | + empty!(dfg.variableCache) |
| 35 | + empty!(dfg.factorCache) |
| 36 | + empty!(dfg.labelDict) |
| 37 | + return nothing |
| 38 | +end |
| 39 | + |
| 40 | +""" |
| 41 | + $(SIGNATURES) |
| 42 | +DANGER: Clears the whole user + robot + sessions from the database. |
| 43 | +""" |
| 44 | +function clearUser!!(dfg::CloudGraphsDFG)::Nothing |
| 45 | + # Perform detach+deletion |
| 46 | + _getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId)) detach delete node ") |
| 47 | + |
| 48 | + # Clearing history |
| 49 | + dfg.addHistory = Symbol[] |
| 50 | + empty!(dfg.variableCache) |
| 51 | + empty!(dfg.factorCache) |
| 52 | + empty!(dfg.labelDict) |
| 53 | + return nothing |
| 54 | +end |
| 55 | + |
| 56 | +""" |
| 57 | + $(SIGNATURES) |
| 58 | +DANGER: Copies and overwrites the destination session. |
| 59 | +If no destination specified then it creates a unique one. |
| 60 | +""" |
| 61 | +function copySession!(sourceDFG::CloudGraphsDFG, destDFG::Union{Nothing, CloudGraphsDFG})::CloudGraphsDFG |
| 62 | + if destDFG == nothing |
| 63 | + destDFG = _getDuplicatedEmptyDFG(sourceDFG) |
| 64 | + end |
| 65 | + _copyIntoGraph!(sourceDFG, destDFG, union(getVariableIds(sourceDFG), getFactorIds(sourceDFG)), true) |
| 66 | + return destDFG |
| 67 | +end |
| 68 | +""" |
| 69 | + $(SIGNATURES) |
| 70 | +DANGER: Copies the source to a new unique destination. |
| 71 | +""" |
| 72 | +copySession!(sourceDFG::CloudGraphsDFG)::CloudGraphsDFG = copySession!(sourceDFG, nothing) |
| 73 | + |
| 74 | + |
| 75 | +getUserData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, "USER"]) |
| 76 | +function setUserData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool |
| 77 | + error("Not implemented yet") |
| 78 | + return true |
| 79 | +end |
| 80 | +getRobotData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, "ROBOT"]) |
| 81 | +function setRobotData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool |
| 82 | + error("Not implemented yet") |
| 83 | + return true |
| 84 | +end |
| 85 | +getSessionData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, dfg.sessionId, "SESSION"]) |
| 86 | +function setSessionData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool |
| 87 | + error("Not implemented yet") |
| 88 | + return true |
| 89 | +end |
0 commit comments