openchs-models 1.31.34 → 1.31.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +1 -1
- package/dist/Schema.js +76 -24
- package/dist/application/Form.js +1 -13
- package/package.json +1 -1
package/.editorconfig
CHANGED
package/dist/Schema.js
CHANGED
|
@@ -221,29 +221,6 @@ function migrateListTypeFieldToEmbedded(newDB, oldDB, schemaName, field, creator
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
function migrateEmbeddedObjects(oldDB, newDB) {
|
|
224
|
-
_MetaDataService.default.forEachObservationField((observationField, schemaName) => {
|
|
225
|
-
migrateListTypeFieldToEmbedded(newDB, oldDB, schemaName, observationField, old => {
|
|
226
|
-
const newConcept = newDB.objects("Concept").filtered(`uuid = "${old.concept.uuid}"`)[0];
|
|
227
|
-
return {
|
|
228
|
-
concept: newConcept,
|
|
229
|
-
valueJSON: old.valueJSON
|
|
230
|
-
};
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
newDB.deleteModel("Observation");
|
|
235
|
-
|
|
236
|
-
_MetaDataService.default.forEachPointField((field, schemaName) => {
|
|
237
|
-
migrateObjectTypeFieldToEmbedded(newDB, oldDB, schemaName, field, old => {
|
|
238
|
-
return {
|
|
239
|
-
x: old.x,
|
|
240
|
-
y: old.y
|
|
241
|
-
};
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
newDB.deleteModel("Point");
|
|
246
|
-
|
|
247
224
|
_MetaDataService.default.forEachFormatField((field, schemaName) => {
|
|
248
225
|
migrateObjectTypeFieldToEmbedded(newDB, oldDB, schemaName, field, old => {
|
|
249
226
|
return {
|
|
@@ -298,10 +275,77 @@ function migrateEmbeddedObjects(oldDB, newDB) {
|
|
|
298
275
|
newDB.deleteModel("StringKeyNumericValue");
|
|
299
276
|
}
|
|
300
277
|
|
|
278
|
+
function flush(db) {
|
|
279
|
+
db.commitTransaction();
|
|
280
|
+
db.beginTransaction();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function shouldFlush(numberOfRecords) {
|
|
284
|
+
const batchSize = 100;
|
|
285
|
+
return numberOfRecords % batchSize === batchSize - 1;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function migrateGeoLocation(oldDB, newDB) {
|
|
289
|
+
flush(newDB);
|
|
290
|
+
let recordCounter = 0;
|
|
291
|
+
|
|
292
|
+
_MetaDataService.default.forEachPointField((field, schemaName) => {
|
|
293
|
+
console.log(`schema: ${schemaName}, field: ${field}`);
|
|
294
|
+
newDB.objects(schemaName).forEach(newDbParentEntity => {
|
|
295
|
+
if (shouldFlush(recordCounter)) {
|
|
296
|
+
flush(newDB);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const oldFieldValue = oldDB.objects(schemaName).filtered(`uuid = "${newDbParentEntity.uuid}"`)[0][field];
|
|
300
|
+
|
|
301
|
+
if (!_lodash.default.isNil(oldFieldValue)) {
|
|
302
|
+
newDbParentEntity[field] = {
|
|
303
|
+
x: oldFieldValue.x,
|
|
304
|
+
y: oldFieldValue.y
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
recordCounter++;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
flush(newDB);
|
|
313
|
+
newDB.deleteModel("Point");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function migrateObservationsToEmbedded(oldDB, newDB) {
|
|
317
|
+
flush(newDB);
|
|
318
|
+
let recordCounter = 0;
|
|
319
|
+
|
|
320
|
+
_MetaDataService.default.forEachObservationField((observationField, schemaName) => {
|
|
321
|
+
console.log(`schema: ${schemaName}, field: ${observationField}`);
|
|
322
|
+
newDB.objects(schemaName).forEach(newDbParentEntity => {
|
|
323
|
+
if (shouldFlush(recordCounter)) {
|
|
324
|
+
flush(newDB);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const newList = [];
|
|
328
|
+
const oldFieldValues = oldDB.objects(schemaName).filtered(`uuid = "${newDbParentEntity.uuid}"`)[0][observationField];
|
|
329
|
+
oldFieldValues.forEach(oldFieldValue => {
|
|
330
|
+
const newConcept = newDB.objects("Concept").filtered(`uuid = "${oldFieldValue.concept.uuid}"`)[0];
|
|
331
|
+
newList.push({
|
|
332
|
+
concept: newConcept,
|
|
333
|
+
valueJSON: oldFieldValue.valueJSON
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
newDbParentEntity[observationField] = newList;
|
|
337
|
+
recordCounter++;
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
flush(newDB);
|
|
342
|
+
newDB.deleteModel("Observation");
|
|
343
|
+
}
|
|
344
|
+
|
|
301
345
|
function createRealmConfig() {
|
|
302
346
|
return {
|
|
303
347
|
//order is important, should be arranged according to the dependency
|
|
304
|
-
schemaVersion:
|
|
348
|
+
schemaVersion: 186,
|
|
305
349
|
onMigration: function (oldDB, newDB) {
|
|
306
350
|
console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
|
|
307
351
|
|
|
@@ -913,6 +957,14 @@ function createRealmConfig() {
|
|
|
913
957
|
if (oldDB.schemaVersion < 184) {
|
|
914
958
|
migrateEmbeddedObjects(oldDB, newDB);
|
|
915
959
|
}
|
|
960
|
+
|
|
961
|
+
if (oldDB.schemaVersion < 185) {
|
|
962
|
+
migrateGeoLocation(oldDB, newDB);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
if (oldDB.schemaVersion < 186) {
|
|
966
|
+
migrateObservationsToEmbedded(oldDB, newDB);
|
|
967
|
+
}
|
|
916
968
|
}
|
|
917
969
|
};
|
|
918
970
|
}
|
package/dist/application/Form.js
CHANGED
|
@@ -66,14 +66,6 @@ class Form extends _BaseEntity.default {
|
|
|
66
66
|
this.that.decisionRule = x;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
get editFormRule() {
|
|
70
|
-
return this.that.editFormRule;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
set editFormRule(x) {
|
|
74
|
-
this.that.editFormRule = x;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
69
|
get visitScheduleRule() {
|
|
78
70
|
return this.that.visitScheduleRule;
|
|
79
71
|
}
|
|
@@ -126,7 +118,7 @@ class Form extends _BaseEntity.default {
|
|
|
126
118
|
this.deleteOutOfSyncDrafts(entityService, resource.uuid);
|
|
127
119
|
}
|
|
128
120
|
|
|
129
|
-
return _General.default.assignFields(resource, new Form(), ["uuid", "name", "formType", "decisionRule", "
|
|
121
|
+
return _General.default.assignFields(resource, new Form(), ["uuid", "name", "formType", "decisionRule", "visitScheduleRule", "taskScheduleRule", "validationRule", "checklistsRule", "taskScheduleRule"]);
|
|
130
122
|
}
|
|
131
123
|
|
|
132
124
|
static deleteOutOfSyncDrafts(entityService, formUUID) {
|
|
@@ -356,10 +348,6 @@ _defineProperty(Form, "schema", {
|
|
|
356
348
|
type: "string",
|
|
357
349
|
optional: true
|
|
358
350
|
},
|
|
359
|
-
editFormRule: {
|
|
360
|
-
type: "string",
|
|
361
|
-
optional: true
|
|
362
|
-
},
|
|
363
351
|
visitScheduleRule: {
|
|
364
352
|
type: "string",
|
|
365
353
|
optional: true
|