-
Notifications
You must be signed in to change notification settings - Fork 0
/
nesb_txml.go
76 lines (73 loc) · 1.5 KB
/
nesb_txml.go
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
package nesbconvertpin
import (
"bufio"
"os"
"path"
"strings"
)
type NesbTxml struct {
Tag string
Service string
Elems []string
}
func nesb_txml() (services map[string]map[string]NesbTxml) {
services = make(map[string]map[string]NesbTxml)
tags := tag_type()
fileName := path.Join(getRootDir(), "etc/enum/nesb_txml.txt")
file, err := os.Open(fileName)
defer file.Close()
if err != nil {
panic(err)
}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if line == "" || strings.HasPrefix(line, "#") || !strings.Contains(line, ".") {
continue
}
kv := strings.Split(line, "\t")
if len(kv) != 2 {
continue
}
ds := strings.Split(kv[0], ".")
if len(ds) != 2 {
continue
}
dtaname := ds[0]
if !strings.Contains(dtaname, "_SVR") && !strings.Contains(dtaname, "_SGET") && !strings.Contains(dtaname, "_PAY") && !strings.Contains(dtaname, "_CLS") {
continue
}
procode := ds[1]
var nt NesbTxml
ts := strings.Split(kv[1], "|")
if len(ts) == 1 {
dds := strings.Split(ts[0], ".")
if len(dds) < 2 {
continue
}
nt.Service = dds[1]
}
if len(ts) == 2 {
nt.Tag = ts[0]
dds := strings.Split(ts[1], ".")
if len(dds) < 2 {
continue
}
nt.Service = dds[1]
nt.Elems = tags[nt.Tag]
}
if nt.Service == "" {
continue
}
dta, ok := services[dtaname]
if !ok {
dta = make(map[string]NesbTxml)
services[dtaname] = dta
}
dta[procode] = nt
}
if err := scanner.Err(); err != nil {
panic(err)
}
return
}