[Pharo] Personal fitness tracker web app.
1
"
2
I implement database persistency for My Fitness Tracker core domain objects.
3
"
4
Class {
5
#name : 'MFTDescriptorSystem',
6
#superclass : 'DescriptorSystem',
7
#category : 'MyFitnessTracker-Glorp',
8
#package : 'MyFitnessTracker-Glorp'
9
}
10
11
{ #category : 'as yet unclassified' }
12
MFTDescriptorSystem class >> defaultDatabaseName [
13
14
^ 'mft.sqlite3'
15
]
16
17
{ #category : 'as yet unclassified' }
18
MFTDescriptorSystem class >> defaultLogin [
19
20
^ Login new
21
database: UDBCSQLite3Platform new;
22
host: Smalltalk imageDirectory fullName;
23
databaseName: self defaultDatabaseName
24
]
25
26
{ #category : 'as yet unclassified' }
27
MFTDescriptorSystem class >> sessionForDefaultLogin [
28
29
^ self sessionForLogin: self defaultLogin
30
]
31
32
{ #category : 'accessing' }
33
MFTDescriptorSystem >> addForeignKeyNamed: fieldName from: sourceTable to: targetTableName [
34
35
| field |
36
field := sourceTable
37
createFieldNamed: fieldName
38
type: platform integer.
39
sourceTable
40
addForeignKeyFrom: field
41
to: ((self tableNamed: targetTableName) fieldNamed: 'id')
42
]
43
44
{ #category : 'accessing' }
45
MFTDescriptorSystem >> addIdTo: aTable [
46
47
(aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey
48
]
49
50
{ #category : 'accessing' }
51
MFTDescriptorSystem >> addStringFieldNamed: aString to: aTable [
52
53
aTable createFieldNamed: aString type: (platform varChar: 255)
54
]
55
56
{ #category : 'accessing' }
57
MFTDescriptorSystem >> addTextFieldNamed: aString to: aTable [
58
59
aTable createFieldNamed: aString type: platform text
60
]
61
62
{ #category : 'accessing' }
63
MFTDescriptorSystem >> allTableNames [
64
65
^ #( 'MFT_EQUIPMENT' 'MFT_MUSCLE' 'MFT_MUSCLE_GROUP'
66
'MFT_EXERCISE' 'MFT_REP_SCHEME' 'MFT_SET_PRESCRIPTION'
67
'MFT_SET_GROUP_PRESCRIPTION' 'MFT_WORKOUT_PRESCRIPTION'
68
'MFT_ROUTINE' 'MFT_SET_LOG' 'MFT_SET_GROUP_LOG'
69
'MFT_WORKOUT_LOG' 'MFT_WORKOUT_LOG_BOOK' 'MFT_TRAINEE'
70
'MFT_MUSCLE_ON_MUSCLE_GROUP' 'MFT_SET_ON_SET_GROUP_PRESCRIPTION'
71
'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION'
72
'MFT_WORKOUT_ON_ROUTINE' 'MFT_SET_LOG_ON_SET_GROUP_LOG'
73
'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG'
74
'MFT_WORKOUT_LOG_ON_LOG_BOOK' )
75
]
76
77
{ #category : 'class models' }
78
MFTDescriptorSystem >> classModelForMFTEquipment: aClassModel [
79
80
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
81
aClassModel newAttributeNamed: #englishName
82
]
83
84
{ #category : 'class models' }
85
MFTDescriptorSystem >> classModelForMFTExercise: aClassModel [
86
87
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
88
aClassModel newAttributeNamed: #englishName.
89
aClassModel newAttributeNamed: #frenchName.
90
"Core currently stores activations as Dictionary<MFTMuscleGroup,Integer>.
91
Do not map it as Integer; persist it via a dedicated activation object in the next domain refactor."
92
aClassModel newAttributeNamed: #equipment type: MFTEquipment
93
]
94
95
{ #category : 'class models' }
96
MFTDescriptorSystem >> classModelForMFTMuscle: aClassModel [
97
98
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
99
aClassModel newAttributeNamed: #latinName.
100
aClassModel newAttributeNamed: #englishName.
101
aClassModel newAttributeNamed: #description
102
]
103
104
{ #category : 'class models' }
105
MFTDescriptorSystem >> classModelForMFTMuscleGroup: aClassModel [
106
107
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
108
aClassModel newAttributeNamed: #englishName.
109
aClassModel newAttributeNamed: #frenchName.
110
aClassModel newAttributeNamed: #muscles collectionOf: MFTMuscle
111
]
112
113
{ #category : 'class models' }
114
MFTDescriptorSystem >> classModelForMFTPreExhaustSupersetGroupPrescription: aClassModel [
115
116
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
117
aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription
118
]
119
120
{ #category : 'class models' }
121
MFTDescriptorSystem >> classModelForMFTRepScheme: aClassModel [
122
123
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
124
aClassModel newAttributeNamed: #minReps.
125
aClassModel newAttributeNamed: #maxReps
126
]
127
128
{ #category : 'class models' }
129
MFTDescriptorSystem >> classModelForMFTRoutine: aClassModel [
130
131
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
132
aClassModel newAttributeNamed: #title.
133
aClassModel
134
newAttributeNamed: #workouts
135
collectionOf: MFTWorkoutPrescription
136
]
137
138
{ #category : 'class models' }
139
MFTDescriptorSystem >> classModelForMFTSet: aClassModel [
140
141
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
142
aClassModel
143
newAttributeNamed: #reps type: Integer;
144
newAttributeNamed: #load type: Float;
145
newAttributeNamed: #workout type: MFTWorkoutPrescription;
146
newAttributeNamed: #exercise type: MFTExercise;
147
newAttributeNamed: #setGroup type: MFTSetGroupPrescription
148
]
149
150
{ #category : 'class models' }
151
MFTDescriptorSystem >> classModelForMFTSetGroup: aClassModel [
152
153
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
154
aClassModel newAttributeNamed: #sets collectionOf: MFTSetLog
155
]
156
157
{ #category : 'class models' }
158
MFTDescriptorSystem >> classModelForMFTSetGroupLog: aClassModel [
159
160
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
161
aClassModel
162
newAttributeNamed: #prescription
163
type: MFTSetGroupPrescription.
164
aClassModel newAttributeNamed: #sets collectionOf: MFTSetLog.
165
aClassModel newAttributeNamed: #notes
166
]
167
168
{ #category : 'class models' }
169
MFTDescriptorSystem >> classModelForMFTSetGroupPrescription: aClassModel [
170
171
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
172
aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription
173
]
174
175
{ #category : 'class models' }
176
MFTDescriptorSystem >> classModelForMFTSetLog: aClassModel [
177
178
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
179
aClassModel newAttributeNamed: #prescription type: MFTSetPrescription.
180
aClassModel newAttributeNamed: #reps.
181
aClassModel newAttributeNamed: #load.
182
aClassModel newAttributeNamed: #failureAchieved
183
]
184
185
{ #category : 'class models' }
186
MFTDescriptorSystem >> classModelForMFTSetPrescription: aClassModel [
187
188
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
189
aClassModel newAttributeNamed: #exercise type: MFTExercise.
190
aClassModel newAttributeNamed: #repScheme type: MFTRepScheme
191
]
192
193
{ #category : 'class models' }
194
MFTDescriptorSystem >> classModelForMFTStraightSetGroupPrescription: aClassModel [
195
196
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
197
aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription
198
]
199
200
{ #category : 'class models' }
201
MFTDescriptorSystem >> classModelForMFTSupersetGroupPrescription: aClassModel [
202
203
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
204
aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription
205
]
206
207
{ #category : 'class models' }
208
MFTDescriptorSystem >> classModelForMFTTrainee: aClassModel [
209
210
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
211
aClassModel newAttributeNamed: #currentRoutine type: MFTRoutine.
212
aClassModel newAttributeNamed: #logBook type: MFTWorkoutLogBook
213
]
214
215
{ #category : 'class models' }
216
MFTDescriptorSystem >> classModelForMFTWeight: aClassModel [
217
218
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
219
aClassModel
220
newAttributeNamed: #date type: Date;
221
newAttributeNamed: #kilograms type: Float;
222
newAttributeNamed: #user type: MFTTrainee
223
]
224
225
{ #category : 'class models' }
226
MFTDescriptorSystem >> classModelForMFTWorkout: aClassModel [
227
228
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
229
aClassModel
230
newAttributeNamed: #user type: MFTTrainee;
231
newAttributeNamed: #routine type: MFTRoutine;
232
newAttributeNamed: #datePlanned type: DateAndTime;
233
newAttributeNamed: #dateCompleted type: DateAndTime;
234
newAttributeNamed: #setGroups collectionOf: MFTSetGroupPrescription
235
]
236
237
{ #category : 'class models' }
238
MFTDescriptorSystem >> classModelForMFTWorkoutLog: aClassModel [
239
240
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
241
aClassModel
242
newAttributeNamed: #prescription
243
type: MFTWorkoutPrescription.
244
aClassModel newAttributeNamed: #start.
245
aClassModel newAttributeNamed: #finish.
246
aClassModel
247
newAttributeNamed: #setGroups
248
collectionOf: MFTSetGroupLog
249
]
250
251
{ #category : 'class models' }
252
MFTDescriptorSystem >> classModelForMFTWorkoutLogBook: aClassModel [
253
254
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
255
aClassModel
256
newAttributeNamed: #workoutLogs
257
collectionOf: MFTWorkoutLog
258
]
259
260
{ #category : 'class models' }
261
MFTDescriptorSystem >> classModelForMFTWorkoutPlan: aClassModel [
262
263
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
264
aClassModel
265
newAttributeNamed: #user type: MFTTrainee;
266
newAttributeNamed: #workouts collectionOf: MFTWorkoutPrescription
267
]
268
269
{ #category : 'class models' }
270
MFTDescriptorSystem >> classModelForMFTWorkoutPrescription: aClassModel [
271
272
(aClassModel newAttributeNamed: #id) useDirectAccess: true.
273
aClassModel newAttributeNamed: #title.
274
aClassModel
275
newAttributeNamed: #setGroups
276
collectionOf: MFTSetGroupPrescription
277
]
278
279
{ #category : 'descriptors' }
280
MFTDescriptorSystem >> descriptorForMFTEquipment: aDescriptor [
281
282
| table |
283
table := self tableNamed: 'MFT_EQUIPMENT'.
284
aDescriptor table: table.
285
self mapIdOf: aDescriptor to: table.
286
self map: #englishName of: aDescriptor to: table
287
]
288
289
{ #category : 'descriptors' }
290
MFTDescriptorSystem >> descriptorForMFTExercise: aDescriptor [
291
292
| table |
293
table := self tableNamed: 'MFT_EXERCISE'.
294
aDescriptor table: table.
295
self mapIdOf: aDescriptor to: table.
296
self map: #englishName of: aDescriptor to: table.
297
self map: #frenchName of: aDescriptor to: table.
298
(aDescriptor newMapping: OneToOneMapping)
299
attributeName: #equipment;
300
referenceClass: MFTEquipment;
301
join: (Join
302
from: (table fieldNamed: 'equipment_id')
303
to: ((self tableNamed: 'MFT_EQUIPMENT') fieldNamed: 'id'))
304
]
305
306
{ #category : 'descriptors' }
307
MFTDescriptorSystem >> descriptorForMFTMuscle: aDescriptor [
308
309
| table |
310
table := self tableNamed: 'MFT_MUSCLE'.
311
aDescriptor table: table.
312
self mapIdOf: aDescriptor to: table.
313
self map: #latinName of: aDescriptor to: table.
314
self map: #englishName of: aDescriptor to: table.
315
self map: #description of: aDescriptor to: table
316
]
317
318
{ #category : 'descriptors' }
319
MFTDescriptorSystem >> descriptorForMFTMuscleGroup: aDescriptor [
320
321
| table link |
322
table := self tableNamed: 'MFT_MUSCLE_GROUP'.
323
link := self tableNamed: 'MFT_MUSCLE_ON_MUSCLE_GROUP'.
324
aDescriptor table: table.
325
self mapIdOf: aDescriptor to: table.
326
self map: #englishName of: aDescriptor to: table.
327
self map: #frenchName of: aDescriptor to: table.
328
(aDescriptor newMapping: ManyToManyMapping)
329
attributeName: #muscles;
330
referenceClass: MFTMuscle;
331
join: (Join
332
from: (table fieldNamed: 'id')
333
to: (link fieldNamed: 'muscle_group_id'));
334
orderBy: [ :each |
335
(each getTable: 'MFT_MUSCLE_ON_MUSCLE_GROUP') getField: 'position' ];
336
writeTheOrderField
337
]
338
339
{ #category : 'descriptors' }
340
MFTDescriptorSystem >> descriptorForMFTPreExhaustSupersetGroupPrescription: aDescriptor [
341
342
| table |
343
table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'.
344
aDescriptor table: table.
345
self mapIdOf: aDescriptor to: table.
346
self mapSetGroupPrescriptionSetsOf: aDescriptor to: table.
347
(self typeResolverFor: MFTSetGroupPrescription)
348
register: aDescriptor
349
keyedBy: 'preExhaust'
350
field: (table fieldNamed: 'kind')
351
]
352
353
{ #category : 'descriptors' }
354
MFTDescriptorSystem >> descriptorForMFTRepScheme: aDescriptor [
355
356
| table |
357
table := self tableNamed: 'MFT_REP_SCHEME'.
358
aDescriptor table: table.
359
self mapIdOf: aDescriptor to: table.
360
self map: #minReps of: aDescriptor to: table.
361
self map: #maxReps of: aDescriptor to: table
362
]
363
364
{ #category : 'descriptors' }
365
MFTDescriptorSystem >> descriptorForMFTRoutine: aDescriptor [
366
367
| table |
368
table := self tableNamed: 'MFT_ROUTINE'.
369
aDescriptor table: table.
370
self mapIdOf: aDescriptor to: table.
371
self map: #title of: aDescriptor to: table.
372
(aDescriptor newMapping: ToManyMapping)
373
attributeName: #workouts;
374
referenceClass: MFTWorkoutPrescription;
375
useLinkTable;
376
join: (Join
377
from: (table fieldNamed: 'id')
378
to:
379
((self tableNamed: 'MFT_WORKOUT_ON_ROUTINE') fieldNamed:
380
'routine_id'));
381
orderBy: [ :each |
382
(each getTable: 'MFT_WORKOUT_ON_ROUTINE') getField: 'position' ];
383
writeTheOrderField
384
]
385
386
{ #category : 'class models' }
387
MFTDescriptorSystem >> descriptorForMFTSet: aDescriptor [
388
389
| table |
390
table := self tableNamed: 'SET'.
391
aDescriptor table: table.
392
aDescriptor directMappingFor: #id.
393
aDescriptor directMappingFor: #reps.
394
aDescriptor directMappingFor: #load.
395
396
(aDescriptor newMapping: DirectMapping)
397
from: #workout
398
to: (table fieldNamed: 'workoutId').
399
400
(aDescriptor newMapping: DirectMapping)
401
from: #exercise
402
to: (table fieldNamed: 'exerciseId').
403
404
(aDescriptor newMapping: DirectMapping)
405
from: #setGroup
406
to: (table fieldNamed: 'setGroupId')
407
]
408
409
{ #category : 'class models' }
410
MFTDescriptorSystem >> descriptorForMFTSetGroup: aDescriptor [
411
412
| table |
413
table := self tableNamed: 'SETGROUP'.
414
aDescriptor table: table.
415
aDescriptor directMappingFor: #id.
416
417
(aDescriptor newMapping: OneToManyMapping)
418
attributeName: #sets;
419
referenceClass: MFTSetLog;
420
join: (Join
421
from: (table fieldNamed: 'id')
422
to: ((self tableNamed: 'SET') fieldNamed: 'setGroupId'))
423
]
424
425
{ #category : 'descriptors' }
426
MFTDescriptorSystem >> descriptorForMFTSetGroupLog: aDescriptor [
427
428
| table |
429
table := self tableNamed: 'MFT_SET_GROUP_LOG'.
430
aDescriptor table: table.
431
self mapIdOf: aDescriptor to: table.
432
self map: #notes of: aDescriptor to: table.
433
(aDescriptor newMapping: OneToOneMapping)
434
attributeName: #prescription;
435
referenceClass: MFTSetGroupPrescription;
436
join: (Join
437
from: (table fieldNamed: 'prescription_id')
438
to:
439
((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed:
440
'id')).
441
(aDescriptor newMapping: ToManyMapping)
442
attributeName: #sets;
443
referenceClass: MFTSetLog;
444
useLinkTable;
445
join: (Join
446
from: (table fieldNamed: 'id')
447
to:
448
((self tableNamed: 'MFT_SET_LOG_ON_SET_GROUP_LOG') fieldNamed:
449
'set_group_log_id'));
450
orderBy: [ :each |
451
(each getTable: 'MFT_SET_LOG_ON_SET_GROUP_LOG') getField:
452
'position' ];
453
writeTheOrderField
454
]
455
456
{ #category : 'descriptors' }
457
MFTDescriptorSystem >> descriptorForMFTSetGroupPrescription: aDescriptor [
458
459
| table |
460
table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'.
461
aDescriptor table: table.
462
self mapIdOf: aDescriptor to: table.
463
self mapSetGroupPrescriptionSetsOf: aDescriptor to: table.
464
(self typeResolverFor: MFTSetGroupPrescription)
465
register: aDescriptor
466
abstract: true
467
]
468
469
{ #category : 'descriptors' }
470
MFTDescriptorSystem >> descriptorForMFTSetLog: aDescriptor [
471
472
| table |
473
table := self tableNamed: 'MFT_SET_LOG'.
474
aDescriptor table: table.
475
self mapIdOf: aDescriptor to: table.
476
self map: #reps of: aDescriptor to: table.
477
self map: #load of: aDescriptor to: table.
478
self map: #failureAchieved of: aDescriptor to: table.
479
(aDescriptor newMapping: OneToOneMapping)
480
attributeName: #prescription;
481
referenceClass: MFTSetPrescription;
482
join: (Join
483
from: (table fieldNamed: 'prescription_id')
484
to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id'))
485
]
486
487
{ #category : 'descriptors' }
488
MFTDescriptorSystem >> descriptorForMFTSetPrescription: aDescriptor [
489
490
| table |
491
table := self tableNamed: 'MFT_SET_PRESCRIPTION'.
492
aDescriptor table: table.
493
self mapIdOf: aDescriptor to: table.
494
(aDescriptor newMapping: OneToOneMapping)
495
attributeName: #exercise;
496
referenceClass: MFTExercise;
497
join: (Join
498
from: (table fieldNamed: 'exercise_id')
499
to: ((self tableNamed: 'MFT_EXERCISE') fieldNamed: 'id')).
500
(aDescriptor newMapping: OneToOneMapping)
501
attributeName: #repScheme;
502
referenceClass: MFTRepScheme;
503
join: (Join
504
from: (table fieldNamed: 'repScheme_id')
505
to: ((self tableNamed: 'MFT_REP_SCHEME') fieldNamed: 'id'))
506
]
507
508
{ #category : 'descriptors' }
509
MFTDescriptorSystem >> descriptorForMFTStraightSetGroupPrescription: aDescriptor [
510
511
| table |
512
table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'.
513
aDescriptor table: table.
514
self mapIdOf: aDescriptor to: table.
515
self mapSetGroupPrescriptionSetsOf: aDescriptor to: table.
516
(self typeResolverFor: MFTSetGroupPrescription)
517
register: aDescriptor
518
keyedBy: 'straight'
519
field: (table fieldNamed: 'kind')
520
]
521
522
{ #category : 'descriptors' }
523
MFTDescriptorSystem >> descriptorForMFTSupersetGroupPrescription: aDescriptor [
524
525
| table |
526
table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'.
527
aDescriptor table: table.
528
self mapIdOf: aDescriptor to: table.
529
self mapSetGroupPrescriptionSetsOf: aDescriptor to: table.
530
(self typeResolverFor: MFTSetGroupPrescription)
531
register: aDescriptor
532
keyedBy: 'superset'
533
field: (table fieldNamed: 'kind')
534
]
535
536
{ #category : 'descriptors' }
537
MFTDescriptorSystem >> descriptorForMFTTrainee: aDescriptor [
538
539
| table |
540
table := self tableNamed: 'MFT_TRAINEE'.
541
aDescriptor table: table.
542
self mapIdOf: aDescriptor to: table.
543
(aDescriptor newMapping: OneToOneMapping)
544
attributeName: #currentRoutine;
545
referenceClass: MFTRoutine;
546
join: (Join
547
from: (table fieldNamed: 'routine_id')
548
to: ((self tableNamed: 'MFT_ROUTINE') fieldNamed: 'id')).
549
(aDescriptor newMapping: OneToOneMapping)
550
attributeName: #logBook;
551
referenceClass: MFTWorkoutLogBook;
552
join: (Join
553
from: (table fieldNamed: 'logBook_id')
554
to: ((self tableNamed: 'MFT_WORKOUT_LOG_BOOK') fieldNamed: 'id'))
555
]
556
557
{ #category : 'class models' }
558
MFTDescriptorSystem >> descriptorForMFTWeight: aDescriptor [
559
560
| table |
561
table := self tableNamed: 'WEIGHT'.
562
aDescriptor table: table.
563
aDescriptor directMappingFor: #id.
564
aDescriptor directMappingFor: #date.
565
aDescriptor directMappingFor: #kilograms.
566
567
(aDescriptor newMapping: DirectMapping)
568
from: #user
569
to: (table fieldNamed: 'userId')
570
]
571
572
{ #category : 'class models' }
573
MFTDescriptorSystem >> descriptorForMFTWorkout: aDescriptor [
574
575
| table link mapping |
576
table := self tableNamed: 'WORKOUT'.
577
aDescriptor table: table.
578
aDescriptor directMappingFor: #id.
579
580
(aDescriptor newMapping: DirectMapping)
581
from: #user
582
to: (table fieldNamed: 'userId').
583
584
(aDescriptor newMapping: DirectMapping)
585
from: #routine
586
to: (table fieldNamed: 'planId').
587
588
aDescriptor directMappingFor: #datePlanned.
589
aDescriptor directMappingFor: #dateCompleted.
590
591
"Workout -> SetGroups via link table"
592
link := self tableNamed: 'WORKOUT_SETGROUP'.
593
594
mapping := aDescriptor newMapping: ManyToManyMapping.
595
mapping
596
attributeName: #setGroups;
597
referenceClass: MFTSetGroupPrescription;
598
join: (Join
599
from: (table fieldNamed: 'id')
600
to: (link fieldNamed: 'workoutId'));
601
joinTo: (Join
602
from: (link fieldNamed: 'setGroupId')
603
to: ((self tableNamed: 'SETGROUP') fieldNamed: 'id'))
604
]
605
606
{ #category : 'descriptors' }
607
MFTDescriptorSystem >> descriptorForMFTWorkoutLog: aDescriptor [
608
609
| table |
610
table := self tableNamed: 'MFT_WORKOUT_LOG'.
611
aDescriptor table: table.
612
self mapIdOf: aDescriptor to: table.
613
self map: #start of: aDescriptor to: table.
614
self map: #finish of: aDescriptor to: table.
615
(aDescriptor newMapping: OneToOneMapping)
616
attributeName: #prescription;
617
referenceClass: MFTWorkoutPrescription;
618
join: (Join
619
from: (table fieldNamed: 'prescription_id')
620
to:
621
((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id')).
622
(aDescriptor newMapping: ToManyMapping)
623
attributeName: #setGroups;
624
referenceClass: MFTSetGroupLog;
625
useLinkTable;
626
join: (Join
627
from: (table fieldNamed: 'id')
628
to:
629
((self tableNamed: 'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG')
630
fieldNamed: 'workout_log_id'));
631
orderBy: [ :each |
632
(each getTable: 'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG') getField:
633
'position' ];
634
writeTheOrderField
635
]
636
637
{ #category : 'descriptors' }
638
MFTDescriptorSystem >> descriptorForMFTWorkoutLogBook: aDescriptor [
639
640
| table |
641
table := self tableNamed: 'MFT_WORKOUT_LOG_BOOK'.
642
aDescriptor table: table.
643
self mapIdOf: aDescriptor to: table.
644
(aDescriptor newMapping: ToManyMapping)
645
attributeName: #workoutLogs;
646
referenceClass: MFTWorkoutLog;
647
useLinkTable;
648
join: (Join
649
from: (table fieldNamed: 'id')
650
to:
651
((self tableNamed: 'MFT_WORKOUT_LOG_ON_LOG_BOOK') fieldNamed:
652
'log_book_id'));
653
orderBy: [ :each |
654
(each getTable: 'MFT_WORKOUT_LOG_ON_LOG_BOOK') getField: 'position' ];
655
writeTheOrderField
656
]
657
658
{ #category : 'class models' }
659
MFTDescriptorSystem >> descriptorForMFTWorkoutPlan: aDescriptor [
660
661
| table |
662
table := self tableNamed: 'WORKOUTPLAN'.
663
aDescriptor table: table.
664
aDescriptor directMappingFor: #id.
665
666
(aDescriptor newMapping: DirectMapping)
667
from: #user
668
to: (table fieldNamed: 'userId').
669
670
(aDescriptor newMapping: OneToManyMapping)
671
attributeName: #workouts;
672
referenceClass: MFTWorkoutPrescription;
673
join: (Join
674
from: (table fieldNamed: 'id')
675
to: ((self tableNamed: 'WORKOUT') fieldNamed: 'planId'))
676
]
677
678
{ #category : 'descriptors' }
679
MFTDescriptorSystem >> descriptorForMFTWorkoutPrescription: aDescriptor [
680
681
| table |
682
table := self tableNamed: 'MFT_WORKOUT_PRESCRIPTION'.
683
aDescriptor table: table.
684
self mapIdOf: aDescriptor to: table.
685
self map: #title of: aDescriptor to: table.
686
(aDescriptor newMapping: ToManyMapping)
687
attributeName: #setGroups;
688
referenceClass: MFTSetGroupPrescription;
689
useLinkTable;
690
join: (Join
691
from: (table fieldNamed: 'id')
692
to: ((self tableNamed: 'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION')
693
fieldNamed: 'workout_prescription_id'));
694
orderBy: [ :each |
695
(each getTable: 'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION') getField:
696
'position' ];
697
writeTheOrderField
698
]
699
700
{ #category : 'accessing' }
701
MFTDescriptorSystem >> map: anAttributeSymbol of: aDescriptor to: aTable [
702
703
(aDescriptor newMapping: DirectMapping)
704
from: anAttributeSymbol
705
to: (aTable fieldNamed: anAttributeSymbol asString)
706
]
707
708
{ #category : 'accessing' }
709
MFTDescriptorSystem >> mapIdOf: aDescriptor to: aTable [
710
711
(aDescriptor newMapping: DirectMapping)
712
from: #id
713
to: (aTable fieldNamed: 'id')
714
]
715
716
{ #category : 'as yet unclassified' }
717
MFTDescriptorSystem >> mapSetGroupPrescriptionSetsOf: aDescriptor to: table [
718
719
(aDescriptor newMapping: ToManyMapping)
720
attributeName: #sets;
721
referenceClass: MFTSetPrescription;
722
useLinkTable;
723
join: (Join
724
from: (table fieldNamed: 'id')
725
to:
726
((self tableNamed: 'MFT_SET_ON_SET_GROUP_PRESCRIPTION')
727
fieldNamed: 'set_group_prescription_id'));
728
orderBy: [ :each |
729
(each getTable: 'MFT_SET_ON_SET_GROUP_PRESCRIPTION') getField:
730
'position' ];
731
writeTheOrderField
732
]
733
734
{ #category : 'tables' }
735
MFTDescriptorSystem >> tableForMFT_ACTIVATED_MUSCLE_GROUP_ON_EXERCISE: aTable [
736
737
| exerciseField muscleGroupField |
738
exerciseField := aTable
739
createFieldNamed: 'exercise_id'
740
type: platform integer.
741
muscleGroupField := aTable
742
createFieldNamed: 'muscle_group_id'
743
type: platform integer.
744
aTable createFieldNamed: 'activation_percent' type: platform integer.
745
aTable
746
addForeignKeyFrom: exerciseField
747
to: ((self tableNamed: 'MFT_EXERCISE') fieldNamed: 'id').
748
aTable
749
addForeignKeyFrom: muscleGroupField
750
to: ((self tableNamed: 'MFT_MUSCLE_GROUP') fieldNamed: 'id')
751
]
752
753
{ #category : 'tables' }
754
MFTDescriptorSystem >> tableForMFT_EQUIPMENT: aTable [
755
756
self addIdTo: aTable.
757
aTable createFieldNamed: 'englishName' type: (platform varChar: 100)
758
]
759
760
{ #category : 'tables' }
761
MFTDescriptorSystem >> tableForMFT_EXERCISE: aTable [
762
763
| equipmentField |
764
self addIdTo: aTable.
765
aTable createFieldNamed: 'englishName' type: (platform varChar: 100).
766
aTable createFieldNamed: 'frenchName' type: (platform varChar: 100).
767
equipmentField := aTable
768
createFieldNamed: 'equipment_id'
769
type: platform integer.
770
aTable
771
addForeignKeyFrom: equipmentField
772
to: ((self tableNamed: 'MFT_EQUIPMENT') fieldNamed: 'id')
773
]
774
775
{ #category : 'tables' }
776
MFTDescriptorSystem >> tableForMFT_MUSCLE: aTable [
777
778
self addIdTo: aTable.
779
aTable createFieldNamed: 'latinName' type: (platform varChar: 120).
780
aTable createFieldNamed: 'englishName' type: (platform varChar: 120).
781
aTable createFieldNamed: 'description' type: platform text
782
]
783
784
{ #category : 'tables' }
785
MFTDescriptorSystem >> tableForMFT_MUSCLE_GROUP: aTable [
786
787
self addIdTo: aTable.
788
self addStringFieldNamed: 'englishName' to: aTable.
789
self addStringFieldNamed: 'frenchName' to: aTable
790
]
791
792
{ #category : 'tables' }
793
MFTDescriptorSystem >> tableForMFT_MUSCLE_ON_MUSCLE_GROUP: aTable [
794
795
| leftField rightField |
796
leftField := (aTable
797
createFieldNamed: 'muscle_group_id'
798
type: platform integer) bePrimaryKey.
799
rightField := (aTable
800
createFieldNamed: 'muscle_id'
801
type: platform integer) bePrimaryKey.
802
aTable createFieldNamed: 'position' type: platform integer.
803
aTable
804
addForeignKeyFrom: leftField
805
to: ((self tableNamed: 'MFT_MUSCLE_GROUP') fieldNamed: 'id').
806
aTable
807
addForeignKeyFrom: rightField
808
to: ((self tableNamed: 'MFT_MUSCLE') fieldNamed: 'id')
809
]
810
811
{ #category : 'tables' }
812
MFTDescriptorSystem >> tableForMFT_PRE_EXHAUST_SUPERSET_GROUP_PRESCRIPTION: aTable [
813
814
self addIdTo: aTable
815
]
816
817
{ #category : 'tables' }
818
MFTDescriptorSystem >> tableForMFT_REP_SCHEME: aTable [
819
820
self addIdTo: aTable.
821
aTable createFieldNamed: 'minReps' type: platform integer.
822
aTable createFieldNamed: 'maxReps' type: platform integer
823
]
824
825
{ #category : 'tables' }
826
MFTDescriptorSystem >> tableForMFT_ROUTINE: aTable [
827
828
self addIdTo: aTable.
829
self addStringFieldNamed: 'title' to: aTable
830
]
831
832
{ #category : 'tables' }
833
MFTDescriptorSystem >> tableForMFT_SET_GROUP_LOG: aTable [
834
835
self addIdTo: aTable.
836
self addTextFieldNamed: 'notes' to: aTable.
837
self
838
addForeignKeyNamed: 'prescription_id'
839
from: aTable
840
to: 'MFT_SET_GROUP_PRESCRIPTION'
841
]
842
843
{ #category : 'tables' }
844
MFTDescriptorSystem >> tableForMFT_SET_GROUP_LOG_ON_WORKOUT_LOG: aTable [
845
846
| leftField rightField |
847
leftField := (aTable
848
createFieldNamed: 'workout_log_id'
849
type: platform integer) bePrimaryKey.
850
rightField := (aTable
851
createFieldNamed: 'set_group_log_id'
852
type: platform integer) bePrimaryKey.
853
aTable createFieldNamed: 'position' type: platform integer.
854
aTable
855
addForeignKeyFrom: leftField
856
to: ((self tableNamed: 'MFT_WORKOUT_LOG') fieldNamed: 'id').
857
aTable
858
addForeignKeyFrom: rightField
859
to: ((self tableNamed: 'MFT_SET_GROUP_LOG') fieldNamed: 'id')
860
]
861
862
{ #category : 'tables' }
863
MFTDescriptorSystem >> tableForMFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION: aTable [
864
865
| leftField rightField |
866
leftField := (aTable
867
createFieldNamed: 'workout_prescription_id'
868
type: platform integer) bePrimaryKey.
869
rightField := (aTable
870
createFieldNamed: 'set_group_prescription_id'
871
type: platform integer) bePrimaryKey.
872
aTable createFieldNamed: 'position' type: platform integer.
873
aTable
874
addForeignKeyFrom: leftField
875
to: ((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id').
876
aTable
877
addForeignKeyFrom: rightField
878
to:
879
((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id')
880
]
881
882
{ #category : 'tables' }
883
MFTDescriptorSystem >> tableForMFT_SET_GROUP_PRESCRIPTION: aTable [
884
885
self addIdTo: aTable.
886
aTable createFieldNamed: 'kind' type: (platform varChar: 32)
887
]
888
889
{ #category : 'tables' }
890
MFTDescriptorSystem >> tableForMFT_SET_LOG: aTable [
891
892
self addIdTo: aTable.
893
aTable createFieldNamed: 'reps' type: platform integer.
894
aTable createFieldNamed: 'load' type: platform double.
895
aTable createFieldNamed: 'failureAchieved' type: platform boolean.
896
self
897
addForeignKeyNamed: 'prescription_id'
898
from: aTable
899
to: 'MFT_SET_PRESCRIPTION'
900
]
901
902
{ #category : 'tables' }
903
MFTDescriptorSystem >> tableForMFT_SET_LOG_ON_SET_GROUP_LOG: aTable [
904
905
| leftField rightField |
906
leftField := (aTable
907
createFieldNamed: 'set_group_log_id'
908
type: platform integer) bePrimaryKey.
909
rightField := (aTable
910
createFieldNamed: 'set_log_id'
911
type: platform integer) bePrimaryKey.
912
aTable createFieldNamed: 'position' type: platform integer.
913
aTable
914
addForeignKeyFrom: leftField
915
to: ((self tableNamed: 'MFT_SET_GROUP_LOG') fieldNamed: 'id').
916
aTable
917
addForeignKeyFrom: rightField
918
to: ((self tableNamed: 'MFT_SET_LOG') fieldNamed: 'id')
919
]
920
921
{ #category : 'tables' }
922
MFTDescriptorSystem >> tableForMFT_SET_ON_PRE_EXHAUST_GROUP: aTable [
923
924
| leftField rightField |
925
leftField := aTable
926
createFieldNamed: 'set_group_prescription_id'
927
type: platform integer.
928
rightField := aTable
929
createFieldNamed: 'set_prescription_id'
930
type: platform integer.
931
aTable createFieldNamed: 'position' type: platform integer.
932
aTable
933
addForeignKeyFrom: leftField
934
to:
935
((self tableNamed: 'MFT_PRE_EXHAUST_SUPERSET_GROUP_PRESCRIPTION')
936
fieldNamed: 'id').
937
aTable
938
addForeignKeyFrom: rightField
939
to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id')
940
]
941
942
{ #category : 'tables' }
943
MFTDescriptorSystem >> tableForMFT_SET_ON_SET_GROUP_PRESCRIPTION: aTable [
944
945
| leftField rightField |
946
leftField := (aTable
947
createFieldNamed: 'set_group_prescription_id'
948
type: platform integer) bePrimaryKey.
949
rightField := (aTable
950
createFieldNamed: 'set_prescription_id'
951
type: platform integer) bePrimaryKey.
952
aTable createFieldNamed: 'position' type: platform integer.
953
aTable
954
addForeignKeyFrom: leftField
955
to:
956
((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id').
957
aTable
958
addForeignKeyFrom: rightField
959
to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id')
960
]
961
962
{ #category : 'tables' }
963
MFTDescriptorSystem >> tableForMFT_SET_ON_STRAIGHT_SET_GROUP: aTable [
964
965
| leftField rightField |
966
leftField := aTable
967
createFieldNamed: 'set_group_prescription_id'
968
type: platform integer.
969
rightField := aTable
970
createFieldNamed: 'set_prescription_id'
971
type: platform integer.
972
aTable createFieldNamed: 'position' type: platform integer.
973
aTable
974
addForeignKeyFrom: leftField
975
to:
976
((self tableNamed: 'MFT_STRAIGHT_SET_GROUP_PRESCRIPTION')
977
fieldNamed: 'id').
978
aTable
979
addForeignKeyFrom: rightField
980
to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id')
981
]
982
983
{ #category : 'tables' }
984
MFTDescriptorSystem >> tableForMFT_SET_ON_SUPERSET_GROUP: aTable [
985
986
| leftField rightField |
987
leftField := aTable
988
createFieldNamed: 'set_group_prescription_id'
989
type: platform integer.
990
rightField := aTable
991
createFieldNamed: 'set_prescription_id'
992
type: platform integer.
993
aTable createFieldNamed: 'position' type: platform integer.
994
aTable
995
addForeignKeyFrom: leftField
996
to:
997
((self tableNamed: 'MFT_SUPERSET_GROUP_PRESCRIPTION') fieldNamed:
998
'id').
999
aTable
1000
addForeignKeyFrom: rightField
1001
to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id')
1002
]
1003
1004
{ #category : 'tables' }
1005
MFTDescriptorSystem >> tableForMFT_SET_PRESCRIPTION: aTable [
1006
1007
self addIdTo: aTable.
1008
self
1009
addForeignKeyNamed: 'exercise_id'
1010
from: aTable
1011
to: 'MFT_EXERCISE'.
1012
self
1013
addForeignKeyNamed: 'repScheme_id'
1014
from: aTable
1015
to: 'MFT_REP_SCHEME'
1016
]
1017
1018
{ #category : 'tables' }
1019
MFTDescriptorSystem >> tableForMFT_STRAIGHT_SET_GROUP_PRESCRIPTION: aTable [
1020
1021
self addIdTo: aTable
1022
]
1023
1024
{ #category : 'tables' }
1025
MFTDescriptorSystem >> tableForMFT_SUPERSET_GROUP_PRESCRIPTION: aTable [
1026
1027
self addIdTo: aTable
1028
]
1029
1030
{ #category : 'tables' }
1031
MFTDescriptorSystem >> tableForMFT_TRAINEE: aTable [
1032
1033
self addIdTo: aTable.
1034
self addForeignKeyNamed: 'routine_id' from: aTable to: 'MFT_ROUTINE'.
1035
self
1036
addForeignKeyNamed: 'logBook_id'
1037
from: aTable
1038
to: 'MFT_WORKOUT_LOG_BOOK'
1039
]
1040
1041
{ #category : 'tables' }
1042
MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG: aTable [
1043
1044
self addIdTo: aTable.
1045
aTable createFieldNamed: 'start' type: platform timestamp.
1046
aTable createFieldNamed: 'finish' type: platform timestamp.
1047
self
1048
addForeignKeyNamed: 'prescription_id'
1049
from: aTable
1050
to: 'MFT_WORKOUT_PRESCRIPTION'
1051
]
1052
1053
{ #category : 'tables' }
1054
MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG_BOOK: aTable [
1055
1056
self addIdTo: aTable
1057
]
1058
1059
{ #category : 'tables' }
1060
MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG_ON_LOG_BOOK: aTable [
1061
1062
| leftField rightField |
1063
leftField := (aTable
1064
createFieldNamed: 'log_book_id'
1065
type: platform integer) bePrimaryKey.
1066
rightField := (aTable
1067
createFieldNamed: 'workout_log_id'
1068
type: platform integer) bePrimaryKey.
1069
aTable createFieldNamed: 'position' type: platform integer.
1070
aTable
1071
addForeignKeyFrom: leftField
1072
to: ((self tableNamed: 'MFT_WORKOUT_LOG_BOOK') fieldNamed: 'id').
1073
aTable
1074
addForeignKeyFrom: rightField
1075
to: ((self tableNamed: 'MFT_WORKOUT_LOG') fieldNamed: 'id')
1076
]
1077
1078
{ #category : 'tables' }
1079
MFTDescriptorSystem >> tableForMFT_WORKOUT_ON_ROUTINE: aTable [
1080
1081
| leftField rightField |
1082
leftField := (aTable
1083
createFieldNamed: 'routine_id'
1084
type: platform integer) bePrimaryKey.
1085
rightField := (aTable
1086
createFieldNamed: 'workout_prescription_id'
1087
type: platform integer) bePrimaryKey.
1088
aTable createFieldNamed: 'position' type: platform integer.
1089
aTable
1090
addForeignKeyFrom: leftField
1091
to: ((self tableNamed: 'MFT_ROUTINE') fieldNamed: 'id').
1092
aTable
1093
addForeignKeyFrom: rightField
1094
to: ((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id')
1095
]
1096
1097
{ #category : 'tables' }
1098
MFTDescriptorSystem >> tableForMFT_WORKOUT_PRESCRIPTION: aTable [
1099
1100
self addIdTo: aTable.
1101
self addStringFieldNamed: 'title' to: aTable
1102
]
1103
1104
{ #category : 'as yet unclassified' }
1105
MFTDescriptorSystem >> typeResolverForMFTSetGroupPrescription [
1106
1107
^ FilteredTypeResolver forRootClass: MFTSetGroupPrescription
1108
]
1109