@@ -21,9 +21,33 @@ import os.log
21
21
/// will contain a single value representing the patient's temperature.
22
22
public struct PCKOutcome : PCKVersionable , PCKSynchronizable {
23
23
24
- public var previousVersionUUIDs : [ UUID ] ?
24
+ public var previousVersionUUIDs : [ UUID ] ? {
25
+ willSet {
26
+ guard let newValue = newValue else {
27
+ previousVersions = nil
28
+ return
29
+ }
30
+ var newPreviousVersions = [ Pointer < Self > ] ( )
31
+ newValue. forEach { newPreviousVersions. append ( Pointer < Self > ( objectId: $0. uuidString) ) }
32
+ previousVersions = newPreviousVersions
33
+ }
34
+ }
35
+
36
+ public var nextVersionUUIDs : [ UUID ] ? {
37
+ willSet {
38
+ guard let newValue = newValue else {
39
+ nextVersions = nil
40
+ return
41
+ }
42
+ var newNextVersions = [ Pointer < Self > ] ( )
43
+ newValue. forEach { newNextVersions. append ( Pointer < Self > ( objectId: $0. uuidString) ) }
44
+ nextVersions = newNextVersions
45
+ }
46
+ }
47
+
48
+ public var previousVersions : [ Pointer < Self > ] ?
25
49
26
- public var nextVersionUUIDs : [ UUID ] ?
50
+ public var nextVersions : [ Pointer < Self > ] ?
27
51
28
52
public var effectiveDate : Date ?
29
53
@@ -186,7 +210,7 @@ public struct PCKOutcome: PCKVersionable, PCKSynchronizable {
186
210
return
187
211
}
188
212
var updated = self
189
- updated = updated. copyRelationalEntities ( previousVersion)
213
+ updated = updated. copyRelational ( previousVersion)
190
214
updated. addToCloud ( delegate, completion: completion)
191
215
192
216
default :
@@ -206,7 +230,6 @@ public struct PCKOutcome: PCKVersionable, PCKSynchronizable {
206
230
}
207
231
completion ( . failure( error) )
208
232
}
209
-
210
233
}
211
234
}
212
235
@@ -260,7 +283,17 @@ public struct PCKOutcome: PCKVersionable, PCKSynchronizable {
260
283
var mutableOutcome = self
261
284
mutableOutcome. logicalClock = cloudClock // Stamp Entity
262
285
mutableOutcome. remoteID = remoteID
286
+ mutableOutcome. addToCloud ( delegate) { result in
287
+
288
+ switch result {
263
289
290
+ case . success:
291
+ completion ( nil )
292
+ case . failure( let error) :
293
+ completion ( error)
294
+ }
295
+ }
296
+ /*
264
297
guard mutableOutcome.deletedDate != nil else {
265
298
266
299
mutableOutcome.addToCloud(delegate) { result in
@@ -285,7 +318,7 @@ public struct PCKOutcome: PCKVersionable, PCKSynchronizable {
285
318
case .failure(let error):
286
319
completion(error)
287
320
}
288
- }
321
+ } */
289
322
}
290
323
291
324
public static func copyValues( from other: PCKOutcome , to here: PCKOutcome ) throws -> Self {
@@ -317,7 +350,6 @@ public struct PCKOutcome: PCKVersionable, PCKSynchronizable {
317
350
318
351
public func copyRelational( _ parse: PCKOutcome ) -> PCKOutcome {
319
352
var copy = self
320
- copy = copy. copyRelationalEntities ( parse)
321
353
if copy. values == nil {
322
354
copy. values = . init( )
323
355
}
0 commit comments