Skip to content

Commit 59fa29a

Browse files
committed
Updating data entries to latest data structure
1 parent e139b0b commit 59fa29a

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
getLabel(entry::AbstractDataEntry) = entry.label
99
getId(entry::AbstractDataEntry) = entry.id
1010
getHash(entry::AbstractDataEntry) = hex2bytes(entry.hash)
11-
getCreatedTimestamp(entry::AbstractDataEntry) = entry.createdTimestamp
11+
getTimestamp(entry::AbstractDataEntry) = entry.timestamp
1212

1313

1414
##==============================================================================
@@ -18,43 +18,44 @@ export BlobStoreEntry
1818

1919
"""
2020
$(TYPEDEF)
21-
Genaral Data Store Entry.
21+
General Data Store Entry.
2222
"""
23-
struct BlobStoreEntry <: AbstractDataEntry
23+
@Base.kwdef struct BlobStoreEntry <: AbstractDataEntry
24+
id::Union{UUID, Nothing}
2425
label::Symbol
25-
id::UUID
2626
blobstore::Symbol
2727
hash::String # Probably https://docs.julialang.org/en/v1/stdlib/SHA
2828
origin::String # E.g. user|robot|session|varlabel
2929
description::String
3030
mimeType::String
31-
createdTimestamp::ZonedDateTime # of when the entry was created
31+
metadata::String
32+
timestamp::ZonedDateTime = now(localzone())
3233
end
3334

3435
_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime*"+00")
3536

3637
# needed for deserialization from JSON during DFG v0.19 transition, see #867
3738
function BlobStoreEntry(;
38-
label,
3939
id,
40+
label,
4041
blobstore,
4142
hash,
4243
origin,
4344
description,
4445
mimeType,
45-
createdTimestamp,
46+
timestamp,
4647
kwargs... # drop excessive fields
4748
)
4849
#
4950
BlobStoreEntry(
50-
Symbol(label),
5151
UUID(id),
52+
Symbol(label),
5253
Symbol(blobstore),
5354
hash,
5455
origin,
5556
description,
5657
mimeType,
57-
_fixtimezone(createdTimestamp),
58+
_fixtimezone(timestamp),
5859
)
5960
end
6061

src/DataBlobs/services/BlobStores.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ end
103103

104104
function updateData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol, entry::AbstractDataEntry, blob::Vector{UInt8}; hashfunction = sha256)
105105
# Recalculate the hash - NOTE Assuming that this is going to be a BlobStoreEntry. TBD.
106-
newEntry = BlobStoreEntry(entry.label, entry.id, blobstore.key, bytes2hex(hashfunction(blob)),
106+
newEntry = BlobStoreEntry(entry.id, entry.label, blobstore.key, bytes2hex(hashfunction(blob)),
107107
buildSourceString(dfg, label),
108-
entry.description, entry.mimeType, entry.createdTimestamp)
108+
entry.description, entry.mimeType, entry.metadata, entry.timestamp)
109109

110110
de = updateDataEntry!(dfg, label, newEntry)
111111
db = updateDataBlob!(blobstore, de, blob)
@@ -136,9 +136,9 @@ function addData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol,
136136
blob::Vector{UInt8}, timestamp=now(localzone()); description="", mimeType = "application/octet-stream", id::UUID = uuid4(), hashfunction = sha256)
137137

138138

139-
entry = BlobStoreEntry(key, id, blobstore.key, bytes2hex(hashfunction(blob)),
139+
entry = BlobStoreEntry(id, key, blobstore.key, bytes2hex(hashfunction(blob)),
140140
buildSourceString(dfg, label),
141-
description, mimeType, timestamp)
141+
description, mimeType, "", timestamp)
142142

143143
addData!(dfg, blobstore, label, entry, blob; hashfunction)
144144
end

test/testBlocks.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,11 @@ function DataEntriesTestBlock!(fg, v2)
850850
# listDataEntries
851851
# emptyDataEntries
852852
# mergeDataEntries
853-
storeEntry = BlobStoreEntry(:a,uuid4(), :b, "","","","",now(localzone()))
853+
storeEntry = BlobStoreEntry(uuid4(), :a, :b, "","","","", "", now(localzone()))
854854
@test getLabel(storeEntry) == storeEntry.label
855855
@test getId(storeEntry) == storeEntry.id
856856
@test getHash(storeEntry) == hex2bytes(storeEntry.hash)
857-
@test getCreatedTimestamp(storeEntry) == storeEntry.createdTimestamp
857+
@test getTimestamp(storeEntry) == storeEntry.timestamp
858858

859859
oid = zeros(UInt8,12); oid[12] = 0x01
860860
de1 = MongodbDataEntry(:key1, uuid4(), NTuple{12,UInt8}(oid), "", now(localzone()))
@@ -903,13 +903,13 @@ end
903903

904904
function blobsStoresTestBlock!(fg)
905905

906-
de1 = BlobStoreEntry(:label1,uuid4(), :store1, "AAAA","origin1","description1","mimetype1",now(localzone()))
907-
de2 = BlobStoreEntry(:label2,uuid4(), :store2, "FFFF","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
908-
de2_update = BlobStoreEntry(:label2,uuid4(), :store2, "0123","origin2","description2","mimetype2",ZonedDateTime("2020-08-12T12:00:01.000+00:00"))
906+
de1 = BlobStoreEntry(uuid4(),:label1, :store1, "AAAA","origin1","description1","mimetype1","", now(localzone()))
907+
de2 = BlobStoreEntry(uuid4(),:label2, :store2, "FFFF","origin2","description2","mimetype2","", ZonedDateTime("2020-08-12T12:00:00.000+00:00"))
908+
de2_update = BlobStoreEntry(uuid4(),:label2, :store2, "0123","origin2","description2","mimetype2","", ZonedDateTime("2020-08-12T12:00:01.000+00:00"))
909909
@test getLabel(de1) == de1.label
910910
@test getId(de1) == de1.id
911911
@test getHash(de1) == hex2bytes(de1.hash)
912-
@test getCreatedTimestamp(de1) == de1.createdTimestamp
912+
@test getTimestamp(de1) == de1.timestamp
913913

914914
#add
915915
var1 = getVariable(fg, :a)

0 commit comments

Comments
 (0)