-
Notifications
You must be signed in to change notification settings - Fork 1
/
MappingValidator.scala
54 lines (40 loc) · 1.2 KB
/
MappingValidator.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.citi.gta
/**
* The class is used to validate GTA mapping string match the
* mapping xml
*/
object MappingValidator {
def validate(str: String, xmlName: String) = {
Mapping(xmlName).get(str) match {
case Some(group) => group
case None => "No Match"
}
}
def main(args: Array[String]) {
println(validate("aaa", "C:\\APAC\\Mapping\\JPN_CHN_HKG_ CALCGROUP_MAPPING.xml"))
}
}
object Mapping {
def apply(name: String) = {
new Mapping(name).toMap
}
}
class Mapping(name: String) {
val ROWMATCH_TAG = "row-match"
val FIELDMATCH_TAG = "field-match"
val OUTPUTROW_TAG = "output-row"
val OUTPUTFIELD_TAG = "output-field"
import scala.collection.immutable.{SortedMap, TreeMap}
def toMap(): SortedMap[String, String] = {
import scala.xml._
val mapping = XML.loadFile(name) \ ROWMATCH_TAG
var rowMatch = new TreeMap[String, String]()
// mapping.toList.map((xml: NodeSeq) => {
// println((xml \ FIELDMATCH_TAG).first \ "@matchvalue")
// // println((xml \ FIELDMATCH_TAG).toList)
// rowMatch = (rowMatch("@value") =
// (xml \ OUTPUTROW_TAG \ OUTPUTFIELD_TAG).toString)
// })
rowMatch
}
}