" I implement database persistency for My Fitness Tracker core domain objects. " Class { #name : 'MFTDescriptorSystem', #superclass : 'DescriptorSystem', #category : 'MyFitnessTracker-Glorp', #package : 'MyFitnessTracker-Glorp' } { #category : 'as yet unclassified' } MFTDescriptorSystem class >> defaultDatabaseName [ ^ 'mft.sqlite3' ] { #category : 'as yet unclassified' } MFTDescriptorSystem class >> defaultLogin [ ^ Login new database: UDBCSQLite3Platform new; host: Smalltalk imageDirectory fullName; databaseName: self defaultDatabaseName ] { #category : 'as yet unclassified' } MFTDescriptorSystem class >> sessionForDefaultLogin [ ^ self sessionForLogin: self defaultLogin ] { #category : 'accessing' } MFTDescriptorSystem >> addForeignKeyNamed: fieldName from: sourceTable to: targetTableName [ | field | field := sourceTable createFieldNamed: fieldName type: platform integer. sourceTable addForeignKeyFrom: field to: ((self tableNamed: targetTableName) fieldNamed: 'id') ] { #category : 'accessing' } MFTDescriptorSystem >> addIdTo: aTable [ (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey ] { #category : 'accessing' } MFTDescriptorSystem >> addStringFieldNamed: aString to: aTable [ aTable createFieldNamed: aString type: (platform varChar: 255) ] { #category : 'accessing' } MFTDescriptorSystem >> addTextFieldNamed: aString to: aTable [ aTable createFieldNamed: aString type: platform text ] { #category : 'accessing' } MFTDescriptorSystem >> allTableNames [ ^ #( 'MFT_EQUIPMENT' 'MFT_MUSCLE' 'MFT_MUSCLE_GROUP' 'MFT_EXERCISE' 'MFT_REP_SCHEME' 'MFT_SET_PRESCRIPTION' 'MFT_SET_GROUP_PRESCRIPTION' 'MFT_WORKOUT_PRESCRIPTION' 'MFT_ROUTINE' 'MFT_SET_LOG' 'MFT_SET_GROUP_LOG' 'MFT_WORKOUT_LOG' 'MFT_WORKOUT_LOG_BOOK' 'MFT_TRAINEE' 'MFT_MUSCLE_ON_MUSCLE_GROUP' 'MFT_SET_ON_SET_GROUP_PRESCRIPTION' 'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION' 'MFT_WORKOUT_ON_ROUTINE' 'MFT_SET_LOG_ON_SET_GROUP_LOG' 'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG' 'MFT_WORKOUT_LOG_ON_LOG_BOOK' ) ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTEquipment: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #englishName ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTExercise: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #englishName. aClassModel newAttributeNamed: #frenchName. "Core currently stores activations as Dictionary. Do not map it as Integer; persist it via a dedicated activation object in the next domain refactor." aClassModel newAttributeNamed: #equipment type: MFTEquipment ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTMuscle: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #latinName. aClassModel newAttributeNamed: #englishName. aClassModel newAttributeNamed: #description ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTMuscleGroup: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #englishName. aClassModel newAttributeNamed: #frenchName. aClassModel newAttributeNamed: #muscles collectionOf: MFTMuscle ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTPreExhaustSupersetGroupPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTRepScheme: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #minReps. aClassModel newAttributeNamed: #maxReps ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTRoutine: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #title. aClassModel newAttributeNamed: #workouts collectionOf: MFTWorkoutPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSet: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #reps type: Integer; newAttributeNamed: #load type: Float; newAttributeNamed: #workout type: MFTWorkoutPrescription; newAttributeNamed: #exercise type: MFTExercise; newAttributeNamed: #setGroup type: MFTSetGroupPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSetGroup: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #sets collectionOf: MFTSetLog ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSetGroupLog: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #prescription type: MFTSetGroupPrescription. aClassModel newAttributeNamed: #sets collectionOf: MFTSetLog. aClassModel newAttributeNamed: #notes ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSetGroupPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSetLog: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #prescription type: MFTSetPrescription. aClassModel newAttributeNamed: #reps. aClassModel newAttributeNamed: #load. aClassModel newAttributeNamed: #failureAchieved ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSetPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #exercise type: MFTExercise. aClassModel newAttributeNamed: #repScheme type: MFTRepScheme ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTStraightSetGroupPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTSupersetGroupPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #sets collectionOf: MFTSetPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTTrainee: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #currentRoutine type: MFTRoutine. aClassModel newAttributeNamed: #logBook type: MFTWorkoutLogBook ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWeight: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #date type: Date; newAttributeNamed: #kilograms type: Float; newAttributeNamed: #user type: MFTTrainee ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWorkout: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #user type: MFTTrainee; newAttributeNamed: #routine type: MFTRoutine; newAttributeNamed: #datePlanned type: DateAndTime; newAttributeNamed: #dateCompleted type: DateAndTime; newAttributeNamed: #setGroups collectionOf: MFTSetGroupPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWorkoutLog: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #prescription type: MFTWorkoutPrescription. aClassModel newAttributeNamed: #start. aClassModel newAttributeNamed: #finish. aClassModel newAttributeNamed: #setGroups collectionOf: MFTSetGroupLog ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWorkoutLogBook: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #workoutLogs collectionOf: MFTWorkoutLog ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWorkoutPlan: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #user type: MFTTrainee; newAttributeNamed: #workouts collectionOf: MFTWorkoutPrescription ] { #category : 'class models' } MFTDescriptorSystem >> classModelForMFTWorkoutPrescription: aClassModel [ (aClassModel newAttributeNamed: #id) useDirectAccess: true. aClassModel newAttributeNamed: #title. aClassModel newAttributeNamed: #setGroups collectionOf: MFTSetGroupPrescription ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTEquipment: aDescriptor [ | table | table := self tableNamed: 'MFT_EQUIPMENT'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #englishName of: aDescriptor to: table ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTExercise: aDescriptor [ | table | table := self tableNamed: 'MFT_EXERCISE'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #englishName of: aDescriptor to: table. self map: #frenchName of: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #equipment; referenceClass: MFTEquipment; join: (Join from: (table fieldNamed: 'equipment_id') to: ((self tableNamed: 'MFT_EQUIPMENT') fieldNamed: 'id')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTMuscle: aDescriptor [ | table | table := self tableNamed: 'MFT_MUSCLE'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #latinName of: aDescriptor to: table. self map: #englishName of: aDescriptor to: table. self map: #description of: aDescriptor to: table ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTMuscleGroup: aDescriptor [ | table link | table := self tableNamed: 'MFT_MUSCLE_GROUP'. link := self tableNamed: 'MFT_MUSCLE_ON_MUSCLE_GROUP'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #englishName of: aDescriptor to: table. self map: #frenchName of: aDescriptor to: table. (aDescriptor newMapping: ManyToManyMapping) attributeName: #muscles; referenceClass: MFTMuscle; join: (Join from: (table fieldNamed: 'id') to: (link fieldNamed: 'muscle_group_id')); orderBy: [ :each | (each getTable: 'MFT_MUSCLE_ON_MUSCLE_GROUP') getField: 'position' ]; writeTheOrderField ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTPreExhaustSupersetGroupPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self mapSetGroupPrescriptionSetsOf: aDescriptor to: table. (self typeResolverFor: MFTSetGroupPrescription) register: aDescriptor keyedBy: 'preExhaust' field: (table fieldNamed: 'kind') ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTRepScheme: aDescriptor [ | table | table := self tableNamed: 'MFT_REP_SCHEME'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #minReps of: aDescriptor to: table. self map: #maxReps of: aDescriptor to: table ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTRoutine: aDescriptor [ | table | table := self tableNamed: 'MFT_ROUTINE'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #title of: aDescriptor to: table. (aDescriptor newMapping: ToManyMapping) attributeName: #workouts; referenceClass: MFTWorkoutPrescription; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_WORKOUT_ON_ROUTINE') fieldNamed: 'routine_id')); orderBy: [ :each | (each getTable: 'MFT_WORKOUT_ON_ROUTINE') getField: 'position' ]; writeTheOrderField ] { #category : 'class models' } MFTDescriptorSystem >> descriptorForMFTSet: aDescriptor [ | table | table := self tableNamed: 'SET'. aDescriptor table: table. aDescriptor directMappingFor: #id. aDescriptor directMappingFor: #reps. aDescriptor directMappingFor: #load. (aDescriptor newMapping: DirectMapping) from: #workout to: (table fieldNamed: 'workoutId'). (aDescriptor newMapping: DirectMapping) from: #exercise to: (table fieldNamed: 'exerciseId'). (aDescriptor newMapping: DirectMapping) from: #setGroup to: (table fieldNamed: 'setGroupId') ] { #category : 'class models' } MFTDescriptorSystem >> descriptorForMFTSetGroup: aDescriptor [ | table | table := self tableNamed: 'SETGROUP'. aDescriptor table: table. aDescriptor directMappingFor: #id. (aDescriptor newMapping: OneToManyMapping) attributeName: #sets; referenceClass: MFTSetLog; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'SET') fieldNamed: 'setGroupId')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTSetGroupLog: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_GROUP_LOG'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #notes of: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #prescription; referenceClass: MFTSetGroupPrescription; join: (Join from: (table fieldNamed: 'prescription_id') to: ((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id')). (aDescriptor newMapping: ToManyMapping) attributeName: #sets; referenceClass: MFTSetLog; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_SET_LOG_ON_SET_GROUP_LOG') fieldNamed: 'set_group_log_id')); orderBy: [ :each | (each getTable: 'MFT_SET_LOG_ON_SET_GROUP_LOG') getField: 'position' ]; writeTheOrderField ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTSetGroupPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self mapSetGroupPrescriptionSetsOf: aDescriptor to: table. (self typeResolverFor: MFTSetGroupPrescription) register: aDescriptor abstract: true ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTSetLog: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_LOG'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #reps of: aDescriptor to: table. self map: #load of: aDescriptor to: table. self map: #failureAchieved of: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #prescription; referenceClass: MFTSetPrescription; join: (Join from: (table fieldNamed: 'prescription_id') to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTSetPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #exercise; referenceClass: MFTExercise; join: (Join from: (table fieldNamed: 'exercise_id') to: ((self tableNamed: 'MFT_EXERCISE') fieldNamed: 'id')). (aDescriptor newMapping: OneToOneMapping) attributeName: #repScheme; referenceClass: MFTRepScheme; join: (Join from: (table fieldNamed: 'repScheme_id') to: ((self tableNamed: 'MFT_REP_SCHEME') fieldNamed: 'id')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTStraightSetGroupPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self mapSetGroupPrescriptionSetsOf: aDescriptor to: table. (self typeResolverFor: MFTSetGroupPrescription) register: aDescriptor keyedBy: 'straight' field: (table fieldNamed: 'kind') ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTSupersetGroupPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self mapSetGroupPrescriptionSetsOf: aDescriptor to: table. (self typeResolverFor: MFTSetGroupPrescription) register: aDescriptor keyedBy: 'superset' field: (table fieldNamed: 'kind') ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTTrainee: aDescriptor [ | table | table := self tableNamed: 'MFT_TRAINEE'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #currentRoutine; referenceClass: MFTRoutine; join: (Join from: (table fieldNamed: 'routine_id') to: ((self tableNamed: 'MFT_ROUTINE') fieldNamed: 'id')). (aDescriptor newMapping: OneToOneMapping) attributeName: #logBook; referenceClass: MFTWorkoutLogBook; join: (Join from: (table fieldNamed: 'logBook_id') to: ((self tableNamed: 'MFT_WORKOUT_LOG_BOOK') fieldNamed: 'id')) ] { #category : 'class models' } MFTDescriptorSystem >> descriptorForMFTWeight: aDescriptor [ | table | table := self tableNamed: 'WEIGHT'. aDescriptor table: table. aDescriptor directMappingFor: #id. aDescriptor directMappingFor: #date. aDescriptor directMappingFor: #kilograms. (aDescriptor newMapping: DirectMapping) from: #user to: (table fieldNamed: 'userId') ] { #category : 'class models' } MFTDescriptorSystem >> descriptorForMFTWorkout: aDescriptor [ | table link mapping | table := self tableNamed: 'WORKOUT'. aDescriptor table: table. aDescriptor directMappingFor: #id. (aDescriptor newMapping: DirectMapping) from: #user to: (table fieldNamed: 'userId'). (aDescriptor newMapping: DirectMapping) from: #routine to: (table fieldNamed: 'planId'). aDescriptor directMappingFor: #datePlanned. aDescriptor directMappingFor: #dateCompleted. "Workout -> SetGroups via link table" link := self tableNamed: 'WORKOUT_SETGROUP'. mapping := aDescriptor newMapping: ManyToManyMapping. mapping attributeName: #setGroups; referenceClass: MFTSetGroupPrescription; join: (Join from: (table fieldNamed: 'id') to: (link fieldNamed: 'workoutId')); joinTo: (Join from: (link fieldNamed: 'setGroupId') to: ((self tableNamed: 'SETGROUP') fieldNamed: 'id')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTWorkoutLog: aDescriptor [ | table | table := self tableNamed: 'MFT_WORKOUT_LOG'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #start of: aDescriptor to: table. self map: #finish of: aDescriptor to: table. (aDescriptor newMapping: OneToOneMapping) attributeName: #prescription; referenceClass: MFTWorkoutPrescription; join: (Join from: (table fieldNamed: 'prescription_id') to: ((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id')). (aDescriptor newMapping: ToManyMapping) attributeName: #setGroups; referenceClass: MFTSetGroupLog; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG') fieldNamed: 'workout_log_id')); orderBy: [ :each | (each getTable: 'MFT_SET_GROUP_LOG_ON_WORKOUT_LOG') getField: 'position' ]; writeTheOrderField ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTWorkoutLogBook: aDescriptor [ | table | table := self tableNamed: 'MFT_WORKOUT_LOG_BOOK'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. (aDescriptor newMapping: ToManyMapping) attributeName: #workoutLogs; referenceClass: MFTWorkoutLog; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_WORKOUT_LOG_ON_LOG_BOOK') fieldNamed: 'log_book_id')); orderBy: [ :each | (each getTable: 'MFT_WORKOUT_LOG_ON_LOG_BOOK') getField: 'position' ]; writeTheOrderField ] { #category : 'class models' } MFTDescriptorSystem >> descriptorForMFTWorkoutPlan: aDescriptor [ | table | table := self tableNamed: 'WORKOUTPLAN'. aDescriptor table: table. aDescriptor directMappingFor: #id. (aDescriptor newMapping: DirectMapping) from: #user to: (table fieldNamed: 'userId'). (aDescriptor newMapping: OneToManyMapping) attributeName: #workouts; referenceClass: MFTWorkoutPrescription; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'WORKOUT') fieldNamed: 'planId')) ] { #category : 'descriptors' } MFTDescriptorSystem >> descriptorForMFTWorkoutPrescription: aDescriptor [ | table | table := self tableNamed: 'MFT_WORKOUT_PRESCRIPTION'. aDescriptor table: table. self mapIdOf: aDescriptor to: table. self map: #title of: aDescriptor to: table. (aDescriptor newMapping: ToManyMapping) attributeName: #setGroups; referenceClass: MFTSetGroupPrescription; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION') fieldNamed: 'workout_prescription_id')); orderBy: [ :each | (each getTable: 'MFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION') getField: 'position' ]; writeTheOrderField ] { #category : 'accessing' } MFTDescriptorSystem >> map: anAttributeSymbol of: aDescriptor to: aTable [ (aDescriptor newMapping: DirectMapping) from: anAttributeSymbol to: (aTable fieldNamed: anAttributeSymbol asString) ] { #category : 'accessing' } MFTDescriptorSystem >> mapIdOf: aDescriptor to: aTable [ (aDescriptor newMapping: DirectMapping) from: #id to: (aTable fieldNamed: 'id') ] { #category : 'as yet unclassified' } MFTDescriptorSystem >> mapSetGroupPrescriptionSetsOf: aDescriptor to: table [ (aDescriptor newMapping: ToManyMapping) attributeName: #sets; referenceClass: MFTSetPrescription; useLinkTable; join: (Join from: (table fieldNamed: 'id') to: ((self tableNamed: 'MFT_SET_ON_SET_GROUP_PRESCRIPTION') fieldNamed: 'set_group_prescription_id')); orderBy: [ :each | (each getTable: 'MFT_SET_ON_SET_GROUP_PRESCRIPTION') getField: 'position' ]; writeTheOrderField ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_ACTIVATED_MUSCLE_GROUP_ON_EXERCISE: aTable [ | exerciseField muscleGroupField | exerciseField := aTable createFieldNamed: 'exercise_id' type: platform integer. muscleGroupField := aTable createFieldNamed: 'muscle_group_id' type: platform integer. aTable createFieldNamed: 'activation_percent' type: platform integer. aTable addForeignKeyFrom: exerciseField to: ((self tableNamed: 'MFT_EXERCISE') fieldNamed: 'id'). aTable addForeignKeyFrom: muscleGroupField to: ((self tableNamed: 'MFT_MUSCLE_GROUP') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_EQUIPMENT: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'englishName' type: (platform varChar: 100) ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_EXERCISE: aTable [ | equipmentField | self addIdTo: aTable. aTable createFieldNamed: 'englishName' type: (platform varChar: 100). aTable createFieldNamed: 'frenchName' type: (platform varChar: 100). equipmentField := aTable createFieldNamed: 'equipment_id' type: platform integer. aTable addForeignKeyFrom: equipmentField to: ((self tableNamed: 'MFT_EQUIPMENT') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_MUSCLE: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'latinName' type: (platform varChar: 120). aTable createFieldNamed: 'englishName' type: (platform varChar: 120). aTable createFieldNamed: 'description' type: platform text ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_MUSCLE_GROUP: aTable [ self addIdTo: aTable. self addStringFieldNamed: 'englishName' to: aTable. self addStringFieldNamed: 'frenchName' to: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_MUSCLE_ON_MUSCLE_GROUP: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'muscle_group_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'muscle_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_MUSCLE_GROUP') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_MUSCLE') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_PRE_EXHAUST_SUPERSET_GROUP_PRESCRIPTION: aTable [ self addIdTo: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_REP_SCHEME: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'minReps' type: platform integer. aTable createFieldNamed: 'maxReps' type: platform integer ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_ROUTINE: aTable [ self addIdTo: aTable. self addStringFieldNamed: 'title' to: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_GROUP_LOG: aTable [ self addIdTo: aTable. self addTextFieldNamed: 'notes' to: aTable. self addForeignKeyNamed: 'prescription_id' from: aTable to: 'MFT_SET_GROUP_PRESCRIPTION' ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_GROUP_LOG_ON_WORKOUT_LOG: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'workout_log_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'set_group_log_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_WORKOUT_LOG') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_GROUP_LOG') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_GROUP_ON_WORKOUT_PRESCRIPTION: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'workout_prescription_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'set_group_prescription_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_GROUP_PRESCRIPTION: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'kind' type: (platform varChar: 32) ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_LOG: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'reps' type: platform integer. aTable createFieldNamed: 'load' type: platform double. aTable createFieldNamed: 'failureAchieved' type: platform boolean. self addForeignKeyNamed: 'prescription_id' from: aTable to: 'MFT_SET_PRESCRIPTION' ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_LOG_ON_SET_GROUP_LOG: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'set_group_log_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'set_log_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_SET_GROUP_LOG') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_LOG') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_ON_PRE_EXHAUST_GROUP: aTable [ | leftField rightField | leftField := aTable createFieldNamed: 'set_group_prescription_id' type: platform integer. rightField := aTable createFieldNamed: 'set_prescription_id' type: platform integer. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_PRE_EXHAUST_SUPERSET_GROUP_PRESCRIPTION') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_ON_SET_GROUP_PRESCRIPTION: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'set_group_prescription_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'set_prescription_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_ON_STRAIGHT_SET_GROUP: aTable [ | leftField rightField | leftField := aTable createFieldNamed: 'set_group_prescription_id' type: platform integer. rightField := aTable createFieldNamed: 'set_prescription_id' type: platform integer. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_STRAIGHT_SET_GROUP_PRESCRIPTION') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_ON_SUPERSET_GROUP: aTable [ | leftField rightField | leftField := aTable createFieldNamed: 'set_group_prescription_id' type: platform integer. rightField := aTable createFieldNamed: 'set_prescription_id' type: platform integer. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_SUPERSET_GROUP_PRESCRIPTION') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_SET_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SET_PRESCRIPTION: aTable [ self addIdTo: aTable. self addForeignKeyNamed: 'exercise_id' from: aTable to: 'MFT_EXERCISE'. self addForeignKeyNamed: 'repScheme_id' from: aTable to: 'MFT_REP_SCHEME' ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_STRAIGHT_SET_GROUP_PRESCRIPTION: aTable [ self addIdTo: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_SUPERSET_GROUP_PRESCRIPTION: aTable [ self addIdTo: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_TRAINEE: aTable [ self addIdTo: aTable. self addForeignKeyNamed: 'routine_id' from: aTable to: 'MFT_ROUTINE'. self addForeignKeyNamed: 'logBook_id' from: aTable to: 'MFT_WORKOUT_LOG_BOOK' ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG: aTable [ self addIdTo: aTable. aTable createFieldNamed: 'start' type: platform timestamp. aTable createFieldNamed: 'finish' type: platform timestamp. self addForeignKeyNamed: 'prescription_id' from: aTable to: 'MFT_WORKOUT_PRESCRIPTION' ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG_BOOK: aTable [ self addIdTo: aTable ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_WORKOUT_LOG_ON_LOG_BOOK: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'log_book_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'workout_log_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_WORKOUT_LOG_BOOK') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_WORKOUT_LOG') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_WORKOUT_ON_ROUTINE: aTable [ | leftField rightField | leftField := (aTable createFieldNamed: 'routine_id' type: platform integer) bePrimaryKey. rightField := (aTable createFieldNamed: 'workout_prescription_id' type: platform integer) bePrimaryKey. aTable createFieldNamed: 'position' type: platform integer. aTable addForeignKeyFrom: leftField to: ((self tableNamed: 'MFT_ROUTINE') fieldNamed: 'id'). aTable addForeignKeyFrom: rightField to: ((self tableNamed: 'MFT_WORKOUT_PRESCRIPTION') fieldNamed: 'id') ] { #category : 'tables' } MFTDescriptorSystem >> tableForMFT_WORKOUT_PRESCRIPTION: aTable [ self addIdTo: aTable. self addStringFieldNamed: 'title' to: aTable ] { #category : 'as yet unclassified' } MFTDescriptorSystem >> typeResolverForMFTSetGroupPrescription [ ^ FilteredTypeResolver forRootClass: MFTSetGroupPrescription ]