@@ -42,6 +42,38 @@ $(METHODLIST)
42
42
function deleteData! end
43
43
44
44
45
+ # cosntruction helper from existing BlobEntry for user overriding via kwargs
46
+ BlobEntry (
47
+ entry:: BlobEntry ;
48
+ id:: Union{UUID,Nothing} = entry. id,
49
+ blobId:: Union{UUID,Nothing} = entry. blobId,
50
+ originId:: UUID = entry. originId,
51
+ label:: Symbol = entry. label,
52
+ blobstore:: Symbol = entry. blobstore,
53
+ hash:: String = entry. hash,
54
+ origin:: String = entry. origin,
55
+ description:: String = entry. description,
56
+ mimeType:: String = entry. mimeType,
57
+ metadata:: String = entry. metadata,
58
+ timestamp:: ZonedDateTime = entry. timestamp,
59
+ _type:: String = entry. _type,
60
+ _version:: String = entry. _version,
61
+ ) = BlobEntry (;
62
+ id,
63
+ blobId,
64
+ originId,
65
+ label,
66
+ blobstore,
67
+ hash,
68
+ origin,
69
+ description,
70
+ mimeType,
71
+ metadata,
72
+ timestamp,
73
+ _type,
74
+ _version
75
+ )
76
+
45
77
function getData (
46
78
dfg:: AbstractDFG ,
47
79
vlabel:: Symbol ,
@@ -97,21 +129,6 @@ function addData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symbol,
97
129
return de=> db
98
130
end
99
131
100
- # TODO check this one
101
- function addData! (
102
- :: Type{<:BlobEntry} ,
103
- dfg:: AbstractDFG ,
104
- label:: Symbol ,
105
- key:: Symbol ,
106
- blob:: AbstractVector{UInt8} ,
107
- timestamp= now (localzone ());
108
- id:: UUID = uuid4 (),
109
- hashfunction:: Function = sha256
110
- )
111
- fde = BlobEntry (key, id, timestamp, blob)
112
- de = addBlobEntry! (dfg, label, fde)
113
- return de=> blob
114
- end
115
132
116
133
addData! (
117
134
dfg:: AbstractDFG ,
@@ -122,30 +139,31 @@ addData!(
122
139
timestamp= now (localzone ());
123
140
kwargs...
124
141
) = addData! (
125
- dfg,
126
- getBlobStore (dfg, blobstorekey),
127
- label,
128
- key,
129
- blob,
130
- timestamp;
131
- kwargs...
132
- )
142
+ dfg,
143
+ getBlobStore (dfg, blobstorekey),
144
+ label,
145
+ key,
146
+ blob,
147
+ timestamp;
148
+ kwargs...
149
+ )
133
150
134
151
function addData! (
135
152
dfg:: AbstractDFG ,
136
153
blobstore:: AbstractBlobStore ,
137
154
label:: Symbol ,
138
155
key:: Symbol ,
139
- blob:: Vector {UInt8} ,
156
+ blob:: AbstractVector {UInt8} ,
140
157
timestamp= now (localzone ());
141
- description= " " ,
158
+ description= " " ,
159
+ metadata = " " ,
142
160
mimeType = " application/octet-stream" ,
143
161
id:: UUID = uuid4 (),
144
162
hashfunction = sha256
145
163
)
146
164
#
147
165
@warn " ID's and origin IDs should be reconciled here."
148
- entry = BlobEntry (
166
+ entry = BlobEntry (;
149
167
id = id,
150
168
originId = id,
151
169
label = key,
@@ -154,7 +172,7 @@ function addData!(
154
172
origin = buildSourceString (dfg, label),
155
173
description = description,
156
174
mimeType = mimeType,
157
- metadata = " " ,
175
+ metadata,
158
176
timestamp = timestamp)
159
177
160
178
addData! (dfg, blobstore, label, entry, blob; hashfunction)
@@ -169,17 +187,29 @@ function updateData!(
169
187
hashfunction = sha256,
170
188
checkhash:: Bool = true
171
189
)
172
- checkhash && assertHash (entry, blob, hashfunction = hashfunction)
190
+ checkhash && assertHash (entry, blob; hashfunction)
173
191
de = updateBlobEntry! (dfg, label, entry)
174
192
db = updateBlob! (dfg, de, blob)
175
193
return de=> db
176
194
end
177
195
178
- function updateData! (dfg:: AbstractDFG , blobstore:: AbstractBlobStore , label:: Symbol , entry:: BlobEntry , blob:: Vector{UInt8} ; hashfunction = sha256)
196
+
197
+ function updateData! (
198
+ dfg:: AbstractDFG ,
199
+ blobstore:: AbstractBlobStore ,
200
+ label:: Symbol ,
201
+ entry:: BlobEntry ,
202
+ blob:: Vector{UInt8} ;
203
+ hashfunction = sha256
204
+ )
179
205
# Recalculate the hash - NOTE Assuming that this is going to be a BlobEntry. TBD.
180
- newEntry = BlobEntry (entry. id, entry. blobId, entry. originId, entry. label, blobstore. key, bytes2hex (hashfunction (blob)),
181
- buildSourceString (dfg, label),
182
- entry. description, entry. mimeType, entry. metadata, entry. timestamp, entry. _type, string (_getDFGVersion ()))
206
+ newEntry = BlobEntry (
207
+ entry; # and kwargs to override new values
208
+ blobstore = blobstore. key,
209
+ hash = string (bytes2hex (hashfunction (blob))),
210
+ origin = buildSourceString (dfg, label),
211
+ _version = string (_getDFGVersion ()),
212
+ )
183
213
184
214
de = updateBlobEntry! (dfg, label, newEntry)
185
215
db = updateBlob! (blobstore, de, blob)
@@ -188,20 +218,34 @@ end
188
218
189
219
function deleteData! (
190
220
dfg:: AbstractDFG ,
191
- label :: Symbol ,
192
- key :: Symbol
221
+ vLbl :: Symbol ,
222
+ bLbl :: Symbol
193
223
)
194
- de = deleteBlobEntry! (dfg, label, key )
224
+ de = deleteBlobEntry! (dfg, vLbl, bLbl )
195
225
db = deleteBlob! (dfg, de)
196
226
return de=> db
197
227
end
198
228
199
229
200
- deleteData! (dfg:: AbstractDFG , blobstore:: AbstractBlobStore , label:: Symbol , entry:: BlobEntry ) =
201
- deleteBlob! (dfg, blobstore, label, entry. label)
230
+ deleteData! (
231
+ dfg:: AbstractDFG ,
232
+ blobstore:: AbstractBlobStore ,
233
+ label:: Symbol ,
234
+ entry:: BlobEntry
235
+ ) = deleteBlob! (
236
+ dfg,
237
+ blobstore,
238
+ label,
239
+ entry. label
240
+ )
202
241
203
- function deleteData! (dfg:: AbstractDFG , blobstore:: AbstractBlobStore , label:: Symbol , key:: Symbol )
204
- de = deleteBlobEntry! (dfg, label, key)
242
+ function deleteData! (
243
+ dfg:: AbstractDFG ,
244
+ blobstore:: AbstractBlobStore ,
245
+ vLbl:: Symbol ,
246
+ bLbl:: Symbol
247
+ )
248
+ de = deleteBlobEntry! (dfg, vLbl, bLbl)
205
249
db = deleteBlob! (blobstore, de)
206
250
return de=> db
207
251
end
0 commit comments