-
Notifications
You must be signed in to change notification settings - Fork 1
/
TimetableElementDto.ts
332 lines (275 loc) · 9.75 KB
/
TimetableElementDto.ts
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
import { IsBoolean, IsDate, IsNumber, IsOptional, IsString, validateSync, ValidationError } from 'class-validator';
export interface TimetableElementFields {
BejelenetettSzamonkeresId?: number;
BejelentettSzamonkeresMod?: string;
BejelentettSzamonkeresTema?: string;
EvesOraSorszam: number;
OsztalyCsoportId?: number;
OsztalyCsoportNev?: string;
Oraszam?: number;
Terem?: string;
Vege: Date;
Naplozart: boolean;
HaziFeladatId?: number;
Nev: string;
ElozoNaplozottOra: string;
ElozoNaplozottOraDatum?: Date;
ElozoNaplozottOraTema?: string;
Kezdete: Date;
Allapot: number;
TantargyId?: number;
HelyettesitoTanarNev?: string;
HelyettesitoTanarUid?: string;
TanarNev?: string;
TanarUid?: string;
Tema?: string;
Tipus: number;
Uid: string;
}
export default class TimetableElementDto implements Partial<TimetableElementFields> {
@IsOptional()
@IsNumber()
private readonly announcedTestId?: number;
@IsOptional()
@IsString()
private readonly announcedTestMode?: string;
@IsOptional()
@IsString()
private readonly announcedTestTopic?: string;
@IsNumber()
private readonly classAnnualSerialNumber?: number;
@IsOptional()
@IsNumber()
private readonly classGroupId?: number;
@IsOptional()
@IsString()
private readonly classGroupName?: string;
@IsOptional()
@IsNumber()
private readonly classScheduleNumber?: number;
@IsOptional()
@IsString()
private readonly classroom?: string;
@IsDate()
private readonly endTime?: Date;
@IsBoolean()
private readonly gradebookClosure?: boolean;
@IsOptional()
@IsNumber()
private readonly homeworkId?: number;
@IsString()
private readonly name?: string;
@IsString()
private readonly previousLoggedLesson?: string;
@IsOptional()
@IsDate()
private readonly previousLoggedLessonDate?: Date;
@IsOptional()
@IsString()
private readonly previousLoggedLessonTopic?: string;
@IsDate()
private readonly startTime?: Date;
@IsNumber()
private readonly status?: number;
@IsOptional()
@IsNumber()
private readonly subjectId?: number;
@IsOptional()
@IsString()
private readonly substituteTeacherName?: string;
@IsOptional()
@IsString()
private readonly substituteTeacherUid?: string;
@IsOptional()
@IsString()
private readonly teacherName?: string;
@IsOptional()
@IsString()
private readonly teacherUid?: string;
@IsOptional()
@IsString()
private readonly topic?: string;
@IsString()
private readonly type?: number;
@IsString()
private readonly uid?: string;
constructor(input: any) {
if (typeof input === 'object' && input !== null) {
this.announcedTestId = typeof input['BejelenetettSzamonkeresId'] === 'number' ? input['BejelenetettSzamonkeresId'] : undefined;
this.announcedTestMode = typeof input['BejelentettSzamonkeresMod'] === 'string' ? input['BejelentettSzamonkeresMod'].trim() :
undefined;
this.announcedTestTopic = typeof input['BejelentettSzamonkeresTema'] === 'string' ? input['BejelentettSzamonkeresTema'].trim() :
undefined;
this.classAnnualSerialNumber = typeof input['EvesOraSorszam'] === 'number' ? input['EvesOraSorszam'] : undefined;
this.classGroupId = typeof input['OsztalyCsoportId'] === 'number' ? input['OsztalyCsoportId'] : undefined;
this.classGroupName = typeof input['OsztalyCsoportNev'] === 'string' ? input['OsztalyCsoportNev'].trim() : undefined;
this.classScheduleNumber = typeof input['Oraszam'] === 'number' ? input['Oraszam'] : undefined;
this.classroom = typeof input['Terem'] === 'string' ? input['Terem'].trim() : undefined;
this.endTime = typeof input['Vege'] === 'string' ? new Date(input['Vege']) : input['Vege'];
this.gradebookClosure = typeof input['Naplozart'] === 'boolean' ? input['Naplozart'] : undefined;
this.homeworkId = typeof input['HaziFeladatId'] === 'number' ? input['HaziFeladatId'] : undefined;
this.name = typeof input['Nev'] === 'string' ? input['Nev'].trim() : undefined;
this.previousLoggedLesson = typeof input['ElozoNaplozottOra'] === 'string' ? input['ElozoNaplozottOra'].trim() : undefined;
this.previousLoggedLessonDate = typeof input['ElozoNaplozottOraDatum'] === 'string' ? new Date(input['ElozoNaplozottOraDatum']) :
input['ElozoNaplozottOraDatum'];
this.previousLoggedLessonTopic = typeof input['ElozoNaplozottOraTema'] === 'string' ? input['ElozoNaplozottOraTema'].trim() :
undefined;
this.startTime = typeof input['Kezdete'] === 'string' ? new Date(input['Kezdete']) : input['Kezdete'];
this.status = typeof input['Allapot'] === 'number' ? input['Allapot'] : undefined;
this.subjectId = typeof input['TantargyId'] === 'number' ? input['TantargyId'] : undefined;
this.substituteTeacherName = typeof input['HelyettesitoTanarNev'] === 'string' ? input['HelyettesitoTanarNev'].trim() : undefined;
this.substituteTeacherUid = typeof input['HelyettesitoTanarUid'] === 'string' ? input['HelyettesitoTanarUid'].trim() : undefined;
this.teacherName = typeof input['TanarNev'] === 'string' ? input['TanarNev'].trim() : undefined;
this.teacherUid = typeof input['TanarUid'] === 'string' ? input['TanarUid'].trim() : undefined;
this.topic = typeof input['Tema'] === 'string' ? input['Tema'].trim() : undefined;
this.type = typeof input['Tipus'] === 'number' ? input['Tipus'] : undefined;
this.uid = typeof input['Uid'] === 'string' ? input['Uid'].trim() : undefined;
}
const errors = validateSync(this, { skipMissingProperties: true });
if (errors.length > 0) {
throw this.validationErrorResponse(errors);
}
}
public get BejelenetettSzamonkeresId(): number | undefined {
return this.announcedTestId;
}
public get BejelentettSzamonkeresMod(): string | undefined {
return this.announcedTestMode;
}
public get BejelentettSzamonkeresTema(): string | undefined {
return this.announcedTestTopic;
}
public get EvesOraSorszam(): number | undefined {
return this.classAnnualSerialNumber;
}
public get OsztalyCsoportId(): number | undefined {
return this.classGroupId;
}
public get OsztalyCsoportNev(): string | undefined {
return this.classGroupName;
}
public get Oraszam(): number | undefined {
return this.classScheduleNumber;
}
public get Terem(): string | undefined {
return this.classroom;
}
public get Vege(): Date | undefined {
return this.endTime;
}
public get Naplozart(): boolean | undefined {
return this.gradebookClosure;
}
public get HaziFeladatId(): number | undefined {
return this.homeworkId;
}
public get Nev(): string | undefined {
return this.name;
}
public get ElozoNaplozottOra(): string | undefined {
return this.previousLoggedLesson;
}
public get ElozoNaplozottOraDatum(): Date | undefined {
return this.previousLoggedLessonDate;
}
public get ElozoNaplozottOraTema(): string | undefined {
return this.previousLoggedLessonTopic;
}
public get Kezdete(): Date | undefined {
return this.startTime;
}
public get Allapot(): number | undefined {
return this.status;
}
public get TantargyId(): number | undefined {
return this.subjectId;
}
public get HelyettesitoTanarNev(): string | undefined {
return this.substituteTeacherName;
}
public get HelyettesitoTanarUid(): string | undefined {
return this.substituteTeacherUid;
}
public get TanarNev(): string | undefined {
return this.teacherName;
}
public get TanarUid(): string | undefined {
return this.teacherUid;
}
public get Tema(): string | undefined {
return this.topic;
}
public get Tipus(): number | undefined {
return this.type;
}
public get Uid(): string | undefined {
return this.uid;
}
public get json(): TimetableElementFields {
return {
Allapot: this.status,
BejelenetettSzamonkeresId: this.announcedTestId,
BejelentettSzamonkeresMod: this.announcedTestMode,
BejelentettSzamonkeresTema: this.announcedTestTopic,
ElozoNaplozottOra: this.previousLoggedLesson,
ElozoNaplozottOraDatum: this.previousLoggedLessonDate,
ElozoNaplozottOraTema: this.previousLoggedLessonTopic,
EvesOraSorszam: this.classAnnualSerialNumber,
HaziFeladatId: this.homeworkId,
HelyettesitoTanarNev: this.substituteTeacherName,
HelyettesitoTanarUid: this.substituteTeacherUid,
Kezdete: this.startTime,
Naplozart: this.gradebookClosure,
Nev: this.name,
Oraszam: this.classScheduleNumber,
OsztalyCsoportId: this.classGroupId,
OsztalyCsoportNev: this.classGroupName,
TanarNev: this.teacherName,
TanarUid: this.teacherUid,
TantargyId: this.subjectId,
Tema: this.topic,
Terem: this.classroom,
Tipus: this.type,
Uid: this.uid,
Vege: this.endTime,
} as TimetableElementFields;
}
private validationErrorResponse(errors: Array<ValidationError>): object {
const validFields: Partial<TimetableElementFields> = {
BejelenetettSzamonkeresId: this.announcedTestId,
BejelentettSzamonkeresMod: this.announcedTestMode,
BejelentettSzamonkeresTema: this.announcedTestTopic,
EvesOraSorszam: this.classAnnualSerialNumber,
OsztalyCsoportId: this.classGroupId,
OsztalyCsoportNev: this.classGroupName,
Oraszam: this.classScheduleNumber,
Terem: this.classroom,
Vege: this.endTime,
Naplozart: this.gradebookClosure,
HaziFeladatId: this.homeworkId,
Nev: this.name,
ElozoNaplozottOra: this.previousLoggedLesson,
ElozoNaplozottOraDatum: this.previousLoggedLessonDate,
ElozoNaplozottOraTema: this.previousLoggedLessonTopic,
Kezdete: this.startTime,
Allapot: this.status,
TantargyId: this.subjectId,
HelyettesitoTanarNev: this.substituteTeacherName,
HelyettesitoTanarUid: this.substituteTeacherUid,
TanarNev: this.teacherName,
TanarUid: this.teacherUid,
Tema: this.topic,
Tipus: this.type,
Uid: this.uid,
};
const errorMessages: Array<string> = [];
for (const error of errors) {
validFields[error.property as keyof TimetableElementFields] = undefined;
errorMessages.push(...Object.values(error.constraints || {}));
}
return {
valid: validFields,
errors: errorMessages,
};
}
}