SHOW:
|
|
- or go back to the newest paste.
1 | case class JobTemplate(jtmId: Option[Int], | |
2 | srcId: Int, | |
3 | name: String, | |
4 | schedule: Option[String], | |
5 | timeZone: Option[String], | |
6 | extractionSQL: String, | |
7 | handler: Option[String], | |
8 | headerTemplate: Option[String], | |
9 | footerTemplate: Option[String], | |
10 | rowTemplate: Option[String], | |
11 | compressor: Option[String], | |
12 | filenameTemplates: Map[String, String], | |
13 | columnTypes: Map[String, String], | |
14 | paramValidators: Map[String, String], | |
15 | createdAt: DateTime, | |
16 | updatedAt: DateTime, | |
17 | isDeleted: Boolean) extends EditableEntity | |
18 | ||
19 | // are we sure in the right order of the values? | |
20 | new JobTemplate(None, "Nielsen", 1, Some(schedule), Some(scheduleTz), selectStatement, Some("DLX"), Some(header), Some(footer), Some(row), Some("bzip2"), .... ) | |
21 | ||
22 | ||
23 | case class JobTemplate(jtmId: Option[Int], | |
24 | srcId: Int, | |
25 | name: String, | |
26 | schedule: Option[Schedule], | |
27 | extractionSQL: String, | |
28 | outputData: OutputData, | |
29 | columnTypes: Map[String, String], | |
30 | paramValidators: Map[String, String], | |
31 | createdAt: DateTime, | |
32 | updatedAt: DateTime, | |
33 | isDeleted: Boolean) extends EditableEntity | |
34 | ||
35 | ||
36 | def toObject(row: Tuple17[Option[Int], String, Int, Option[String], | |
37 | Option[String], String, Option[String], Option[String], Option[String], | |
38 | Option[String], Option[String], Map[String, String], | |
39 | Map[String, String], Map[String, String], DateTime, DateTime, Boolean]): JobTemplate = | |
40 | row match { | |
41 | case (jtmId, name, srcId, schedule, timeZone, extractionSQL, handler, | |
42 | headerTemplate, footerTemplate, rowTemplate, compressor, filenameTemplates, | |
43 | columnTypes, paramValidators, createdAt, updatedAt, isDeleted) => { | |
44 | val outputData = new OutputData(handler, headerTemplate, | |
45 | footerTemplate, rowTemplate, compressor, filenameTemplates) | |
46 | val schedule = for { | |
47 | sh <- schedule | |
48 | tz <- timeZone | |
49 | } yield new Schedule(sh, tz) | |
50 | new JobTemplate(jtmId, name, srcId, schedule, extractionSQL, outputData, | |
51 | columnTypes, paramValidators, createdAt, updatedAt, isDeleted) | |
52 | } | |
53 | } | |
54 | ||
55 | ||
56 | val jobTemplate = new model.JobTemplate( | |
57 | jtmId = None, | |
58 | name = "Nielsen", | |
59 | srcId = 1, | |
60 | schedule = Some(schedule), | |
61 | timeZone = Some(scheduleTz), | |
62 | extractionSQL = selectStatement, | |
63 | handler = Some("DLX"), | |
64 | headerTemplate = Some(header), | |
65 | footerTemplate = Some(footer), | |
66 | rowTemplate = Some(row), | |
67 | compressor = Some("bzip2"), | |
68 | filenameTemplates = Map("log" -> logFileName, "meta" -> metaFileName), | |
69 | columnTypes = colTypes, | |
70 | paramValidators = parValidators, | |
71 | createdAt = now, | |
72 | updatedAt = now, | |
73 | isDeleted = ACTIVE.value) |