-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathExerciseDC.kt
More file actions
205 lines (202 loc) · 6.25 KB
/
Copy pathExerciseDC.kt
File metadata and controls
205 lines (202 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright (c) 2025-2026. The LibreFit Contributors
*
* LibreFit is subject to additional terms covering author attribution and trademark usage;
* see the ADDITIONAL_TERMS.md and TRADEMARK_POLICY.md files in the project root.
*/
package org.librefit.db.entity
import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable
import org.librefit.enums.exercise.Category
import org.librefit.enums.exercise.Equipment
import org.librefit.enums.exercise.Force
import org.librefit.enums.exercise.Level
import org.librefit.enums.exercise.Mechanic
import org.librefit.enums.exercise.Muscle
/**
* This data class stores exercises as parsed from `res/raw/exercises.json`. The dataset in provided by [org.librefit.db.repository.DatasetRepository]
* `kotlin.serialization` is used for JSON serialization and deserialization as indicated by
* [Serializable] annotation. The actual exercise entries in database are handled by [Exercise]
*
* The JSON schema associated with this class is defined as follows:
*
* ```json
* {
* "$schema": "http://json-schema.org/draft-04/schema#",
* "type": "object",
* "properties": {
* "id": {
* "type": "string",
* "pattern": "^[0-9a-zA-Z_-]+$"
* },
* "name": {
* "type": "string"
* },
* "force": {
* "type": [ "string", "null" ],
* "enum": [
* null,
* "static",
* "pull",
* "push"
* ]
* },
* "level": {
* "type": "string",
* "enum": [
* "beginner",
* "intermediate",
* "expert"
* ]
* },
* "mechanic": {
* "type": [ "string", "null" ],
* "enum": [
* "isolation",
* "compound",
* null
* ]
* },
* "equipment": {
* "type": [ "string", "null" ],
* "enum": [
* null,
* "medicine ball",
* "dumbbell",
* "body only",
* "bands",
* "kettlebells",
* "foam roll",
* "cable",
* "machine",
* "barbell",
* "exercise ball",
* "e-z curl bar",
* "other"
* ]
* },
* "primaryMuscles": {
* "type": "array",
* "items": [
* {
* "type": "string",
* "enum": [
* "abdominals",
* "abductors",
* "adductors",
* "biceps",
* "calves",
* "chest",
* "forearms",
* "glutes",
* "hamstrings",
* "lats",
* "lower back",
* "middle back",
* "neck",
* "quadriceps",
* "shoulders",
* "traps",
* "triceps"
* ]
* }
* ]
* },
* "secondaryMuscles": {
* "type": "array",
* "items": [
* {
* "type": "string",
* "enum": [
* "abdominals",
* "abductors",
* "adductors",
* "biceps",
* "calves",
* "chest",
* "forearms",
* "glutes",
* "hamstrings",
* "lats",
* "lower back",
* "middle back",
* "neck",
* "quadriceps",
* "shoulders",
* "traps",
* "triceps"
* ]
* }
* ]
* },
* "instructions": {
* "type": "array",
* "items": [{ "type": "string" }]
* },
* "category": {
* "type": "string",
* "enum": [
* "powerlifting",
* "strength",
* "stretching",
* "cardio",
* "olympic weightlifting",
* "strongman",
* "plyometrics"
* ]
* },
* "images": {
* "type": "array",
* "items": [{ "type": "string" }]
* }
* },
* "required": [
* "id",
* "name",
* "level",
* "mechanic",
* "equipment",
* "primaryMuscles",
* "secondaryMuscles",
* "instructions",
* "category",
* "images"
* ]
* }
* ```
*
*
* @property id Unique identifier for the exercise (e.g., "Pull-up"). Must match the pattern "^[0-9a-zA-Z_-]+$".
* @property name Name of the exercise.
* @property force The [org.librefit.enums.exercise.Force] type applied during the exercise. Acceptable values are defined in the JSON schema.
* @property level The difficulty [org.librefit.enums.exercise.Level] of the exercise. Acceptable values are defined in the JSON schema.
* @property mechanic The exercise [org.librefit.enums.exercise.Mechanic]. Acceptable values are defined in the JSON schema.
* @property equipment The [org.librefit.enums.exercise.Equipment] required for the exercise. Acceptable values are defined in the JSON schema.
* @property primaryMuscles List of primary [org.librefit.enums.exercise.Muscle]s involved in the exercise. Acceptable values are defined in the JSON schema.
* @property secondaryMuscles List of secondary [org.librefit.enums.exercise.Muscle]s involved in the exercise. Acceptable values are defined in the JSON schema.
* @property instructions Step-by-step instructions detailing how to perform the exercise.
* @property category The [org.librefit.enums.exercise.Category] of the exercise. Acceptable values are defined in the JSON schema.
* @property images Identifiers of images associated with the exercise.
* @property isCustomExercise It tells whether this exercise is created by the user or not. By default,
* the exercise comes from `exercises.json` so it is set to `false`.
*/
@Serializable
@Entity(tableName = "dataset")
data class ExerciseDC(
@PrimaryKey val id: String = "",
val name: String = "",
val force: Force? = null,
val level: Level = Level.BEGINNER,
val mechanic: Mechanic? = null,
val equipment: Equipment? = null,
val primaryMuscles: List<Muscle> = listOf(),
val secondaryMuscles: List<Muscle> = listOf(),
val instructions: List<String> = listOf(),
val category: Category = Category.POWERLIFTING,
val images: List<String> = listOf(),
val isCustomExercise: Boolean = false,
/** Common mistakes and cautions for the exercise (user-facing text). */
val cautions: String = ""
)