-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTransformationContext.scala
37 lines (27 loc) · 1.01 KB
/
TransformationContext.scala
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
package diamond.transform
import diamond.models.{JobStep, TransformationError}
import scala.collection.mutable
/**
*
* Use this like any map to pass state between transformations if required.
*
* Required default state includes:
* * errors List[TransformationError] accumulates errors during transformation
* * steps List[JobStep] accumulates completed or failed job steps
* * sqlparams Map[String, String] params, such as environment variables, to
* inject into SQL statements
*
* Created by markmo on 12/12/2015.
*/
class TransformationContext extends Serializable {
val map = mutable.Map[String, Any]()
apply("errors", List[TransformationError]())
apply("steps", List[JobStep]())
apply("sqlparams", Map[String, String]())
def apply(key: String, value: Any): Unit = {
map.put(key, value)
}
def apply(key: String) = map(key)
def getOrElse(key: String, default: Any) = map.getOrElse(key, default)
def contains(key: String) = map.contains(key)
}