Skip to content

Commit 03d4261

Browse files
committed
Fix CGDFG data entries
1 parent b899df6 commit 03d4261

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ function getVariable(dfg::CloudGraphsDFG, label::Union{Symbol, String})
239239
for solveKey in listVariableSolverData(dfg, label)
240240
variable.solverDataDict[solveKey] = getVariableSolverData(dfg, label, solveKey)
241241
end
242-
dataDict = getDataEntries(dfg, label)
243-
for (k,v) in dataDict
244-
variable.dataDict[k] = v
242+
dataSet = getDataEntries(dfg, label)
243+
for v in dataSet
244+
variable.dataDict[v.label] = v
245245
end
246246

247247
return variable
@@ -258,7 +258,7 @@ function mergeVariableData!(dfg::CloudGraphsDFG, sourceVariable::DFGVariable; cu
258258
updateVariableSolverData!(dfg, getLabel(sourceVariable), v, currentTransaction=currentTransaction)
259259
end
260260
for (k,v) in sourceVariable.dataDict
261-
updateDatEntry!(dfg, getLabel(sourceVariable), v, currentTransaction=currentTransaction)
261+
updateDataEntry!(dfg, getLabel(sourceVariable), v, currentTransaction=currentTransaction)
262262
end
263263
return sourceVariable
264264
end
@@ -643,11 +643,9 @@ end
643643
function getDataEntries(dfg::CloudGraphsDFG, label::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
644644
entries = Dict{Symbol, BlobStoreEntry}()
645645
# TODO: Optimize if necessary.
646-
for key in listDataEntries(dfg, label, currentTransaction=currentTransaction)
647-
entry = getDataEntry(dfg, label, key, currentTransaction=currentTransaction)
648-
entries[entry.label] = entry
649-
end
650-
return entries
646+
delist = listDataEntries(dfg, label, currentTransaction=currentTransaction)
647+
return getDataEntry.(dfg, label, delist; currentTransaction)
648+
651649
end
652650

653651
function listDataEntries(dfg::CloudGraphsDFG, label::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)
@@ -665,6 +663,10 @@ function getDataEntry(dfg::CloudGraphsDFG, label::Symbol, key::Symbol; currentTr
665663
BlobStoreEntry,
666664
key;
667665
currentTransaction=currentTransaction)
666+
667+
#FIXME
668+
properties["createdTimestamp"] = DistributedFactorGraphs.getStandardZDTString(properties["createdTimestamp"])
669+
668670
return Unmarshal.unmarshal(
669671
BlobStoreEntry,
670672
properties)
@@ -681,6 +683,10 @@ function addDataEntry!(dfg::CloudGraphsDFG, label::Symbol, bde::BlobStoreEntry;
681683
bde,
682684
:DATA,
683685
currentTransaction=currentTransaction)
686+
687+
#FIXME
688+
packed["createdTimestamp"] = DistributedFactorGraphs.getStandardZDTString(packed["createdTimestamp"])
689+
684690
return Unmarshal.unmarshal(
685691
BlobStoreEntry,
686692
packed)
@@ -697,6 +703,10 @@ function updateDataEntry!(dfg::CloudGraphsDFG, label::Symbol, bde::BlobStoreEnt
697703
bde,
698704
:DATA,
699705
currentTransaction=currentTransaction)
706+
707+
#FIXME
708+
packed["createdTimestamp"] = DistributedFactorGraphs.getStandardZDTString(packed["createdTimestamp"])
709+
700710
return Unmarshal.unmarshal(
701711
BlobStoreEntry,
702712
packed)
@@ -710,6 +720,10 @@ function deleteDataEntry!(dfg::CloudGraphsDFG, label::Symbol, key::Symbol; curre
710720
_getLabelsForType(dfg, BlobStoreEntry, parentKey=label),
711721
key,
712722
currentTransaction=currentTransaction)
723+
724+
#FIXME
725+
props["createdTimestamp"] = DistributedFactorGraphs.getStandardZDTString(props["createdTimestamp"])
726+
713727
return Unmarshal.unmarshal(
714728
BlobStoreEntry,
715729
props)

test/interfaceTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ end
117117
DataEntriesTestBlock!(fg1, var2)
118118
end
119119
@testset "Data blob tests" begin
120-
blobsStoresTestBlock!(fg1, var2)
120+
blobsStoresTestBlock!(fg1)
121121
end
122122
end
123123

test/testBlocks.jl

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -868,16 +868,11 @@ function DataEntriesTestBlock!(fg, v2)
868868
deleteDataEntry!(fg, :b, :key2)
869869
end
870870

871-
function blobsStoresTestBlock!(fg, v1)
871+
function blobsStoresTestBlock!(fg)
872872

873873
de1 = BlobStoreEntry(:label1,uuid4(), :store1, "AAAA","origin1","description1","mimetype1",now(localzone()))
874-
# TODO put this one in. It breaks current serialization.
875-
@warn "FIXME ZonedDateTime tests for: 2020-08-12T12:00:00.000+00:00)"
876-
@test_skip false
877-
#de2 = BlobStoreEntry(:label2,uuid4(), :store2, "FFFF","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
878-
de2 = BlobStoreEntry(:label2,uuid4(), :store2, "FFFF","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:00.001+00:00"))
879-
# de2_update = BlobStoreEntry(:label2,uuid4(), :store2, "0123","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:01.000+00:00"))
880-
de2_update = BlobStoreEntry(:label2,uuid4(), :store2, "0123","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:01.001+00:00"))
874+
de2 = BlobStoreEntry(:label2,uuid4(), :store2, "FFFF","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
875+
de2_update = BlobStoreEntry(:label2,uuid4(), :store2, "0123","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:01.000+00:00"))
881876
@test getLabel(de1) == de1.label
882877
@test getId(de1) == de1.id
883878
@test getHash(de1) == hex2bytes(de1.hash)
@@ -886,9 +881,10 @@ function blobsStoresTestBlock!(fg, v1)
886881
#add
887882
var1 = getVariable(fg, :a)
888883
@test addDataEntry!(var1, de1) == de1
884+
updateVariable!(fg, var1)
889885
@test addDataEntry!(fg, :a, de2) == de2
890886
@test_throws ErrorException addDataEntry!(var1, de1)
891-
@test de2 in getDataEntries(var1)
887+
@test de2 in getDataEntries(fg, var1.label)
892888

893889
#get
894890
@test deepcopy(de1) == getDataEntry(var1, :label1)
@@ -911,10 +907,11 @@ function blobsStoresTestBlock!(fg, v1)
911907
@test listDataEntries(fg, :b) == Symbol[:label2]
912908

913909
#delete
914-
@test deleteDataEntry!(var1, de1) == de1
915-
@test listDataEntries(var1) == Symbol[:label2]
910+
@test deleteDataEntry!(fg, var1.label, de1.label) == de1
911+
@test listDataEntries(fg, var1.label) == Symbol[:label2]
916912
#delete from dfg
917913
@test deleteDataEntry!(fg, :a, :label2) == de2_update
914+
var1 = getVariable(fg, :a)
918915
@test listDataEntries(var1) == Symbol[]
919916

920917
# Blobstore functions
@@ -939,19 +936,19 @@ function blobsStoresTestBlock!(fg, v1)
939936
# Data functions
940937
testData = rand(UInt8, 50)
941938
# Adding
942-
newData = addData!(fg, fs.key, getLabel(v1), :testing, testData)
939+
newData = addData!(fg, fs.key, :a, :testing, testData)
943940
# Listing
944-
@test :testing in listDataEntries(fg, getLabel(v1))
941+
@test :testing in listDataEntries(fg, :a)
945942
# Getting
946-
data = getData(fg, fs, getLabel(v1), :testing)
943+
data = getData(fg, fs, :a, :testing)
947944
@test data[1].hash == newData[1].hash
948945
@test data[2] == newData[2]
949946
# Updating
950-
updateData = updateData!(fg, fs, getLabel(v1), newData[1], rand(UInt8, 50))
947+
updateData = updateData!(fg, fs, :a, newData[1], rand(UInt8, 50))
951948
@test updateData[1].hash != data[1].hash
952949
@test updateData[2] != data[2]
953950
# Deleting
954-
retData = deleteData!(fg, getLabel(v1), :testing)
951+
retData = deleteData!(fg, :a, :testing)
955952

956953
end
957954

0 commit comments

Comments
 (0)