@@ -44,15 +44,16 @@ function getDataEntry(var::AbstractDFGVariable, blobId::UUID)
44
44
error (" No dataEntry with blobId $(blobId) found in variable $(getLabel (var)) " )
45
45
end
46
46
47
- getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: Union{Symbol,UUID} ) = getDataEntry (getVariable (dfg, label), key)
47
+ getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: UUID ) = getDataEntry (getVariable (dfg, label), key)
48
+ getDataEntry (dfg:: AbstractDFG , label:: Symbol , key:: Symbol ) = getDataEntry (getVariable (dfg, label), key)
48
49
49
50
50
51
"""
51
52
$(SIGNATURES)
52
53
Add Data Entry to a DFG variable
53
54
Should be extended if DFG variable is not returned by reference.
54
55
55
- Also see: [`getDataEntry`](@ref), [`addDataBlob`](@ref), [`copyDataEntry !`](@ref)
56
+ Also see: [`getDataEntry`](@ref), [`addDataBlob`](@ref), [`mergeDataEntries !`](@ref)
56
57
"""
57
58
function addDataEntry! (var:: AbstractDFGVariable , bde:: AbstractDataEntry )
58
59
haskey (var. dataDict, bde. label) && error (" Data entry $(bde. label) already exists in variable $(getLabel (var)) " )
@@ -181,14 +182,34 @@ in a source variable.
181
182
182
183
See also: [`addDataEntry!`](@ref), [`getDataEntry`](@ref), [`listDataEntries`](@ref), [`getDataBlob`](@ref)
183
184
"""
184
- function copyDataEntry ! (
185
+ function mergeDataEntries ! (
185
186
dst:: AbstractDFG ,
186
187
dlbl:: Symbol ,
187
188
src:: AbstractDFG ,
188
189
slbl:: Symbol ,
189
190
bllb:: Union{Symbol, UUID, <:AbstractString, Regex}
190
191
)
191
192
#
192
- de = getDataEntry (src, slbl, bllb)
193
- addDataEntry! (dst, dlbl, de)
193
+ des = getDataEntry (src, slbl, bllb)
194
+ # don't add data entries that already exist
195
+ dde = listDataEntries (dst, dlbl)
196
+ uids = (s-> s. id). (dde)
197
+ filter! (s -> ! (s. id in uids), des)
198
+ # add any data entries not already in the destination variable, by uuid
199
+ addDataEntry! .(dst, dlbl, des)
200
+ end
201
+
202
+ function mergeDataEntries! (
203
+ dst:: AbstractDFG ,
204
+ dlbl:: Symbol ,
205
+ src:: AbstractDFG ,
206
+ slbl:: Symbol ,
207
+ :: Colon = :
208
+ )
209
+ des = listDataEntries (src, slbl)
210
+ # don't add data entries that already exist
211
+ dde = listDataEntries (dst, dlbl)
212
+ uids = (s-> s. id). (dde)
213
+ filter! (s -> ! (s. id in uids), des)
214
+ union (((s-> mergeDataEntries! (dst, dlbl, src, slbl, s. id)). (des)). .. )
194
215
end
0 commit comments