@@ -3,13 +3,16 @@ import { ConflictResolutionStrategy } from "../../conflict-resolution/auto-resol
3
3
import { AttendanceMonth } from "./model/attendance-month" ;
4
4
import _ from "lodash" ;
5
5
import { diff } from "deep-object-diff" ;
6
+ import { EntitySchemaService } from "../../core/entity/schema/entity-schema.service" ;
6
7
7
8
/**
8
9
* Auto resolve simple database document conflicts concerning {@link AttendanceMonth} entities.
9
10
*/
10
11
@Injectable ( )
11
12
export class AttendanceMonthConflictResolutionStrategy
12
13
implements ConflictResolutionStrategy {
14
+ constructor ( private entitySchemaService : EntitySchemaService ) { }
15
+
13
16
/**
14
17
* Checks if the given conflict is about AttendanceMonth entities (otherwise this strategy doesn't apply)
15
18
* and suggests whether the conflict is trivial and can be automatically deleted.
@@ -24,6 +27,17 @@ export class AttendanceMonthConflictResolutionStrategy
24
27
return false ;
25
28
}
26
29
30
+ if ( typeof currentDoc . getId === "function" ) {
31
+ currentDoc = this . entitySchemaService . transformEntityToDatabaseFormat (
32
+ currentDoc
33
+ ) ;
34
+ }
35
+ if ( typeof conflictingDoc . getId === "function" ) {
36
+ conflictingDoc = this . entitySchemaService . transformEntityToDatabaseFormat (
37
+ conflictingDoc
38
+ ) ;
39
+ }
40
+
27
41
const currentDocC = _ . merge ( { } , currentDoc ) ;
28
42
delete currentDocC . _rev ;
29
43
const conflictingDocC = _ . merge ( { } , conflictingDoc ) ;
@@ -53,6 +67,10 @@ export class AttendanceMonthConflictResolutionStrategy
53
67
null ,
54
68
] ) ;
55
69
70
+ console . log ( currentDoc ) ;
71
+ console . log ( conflictingDoc ) ;
72
+ console . log ( "isIrrelevantAttendanceMonthConflict" , simplifiedDiff ) ;
73
+
56
74
return _ . isObjectLike ( simplifiedDiff ) && _ . isEmpty ( simplifiedDiff ) ;
57
75
}
58
76
0 commit comments