-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconsts.go
225 lines (207 loc) · 5.36 KB
/
consts.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
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
package main
import (
"os"
"strings"
)
const (
currentVersion = "0.9.15"
currentTitle = "Applications Packager " + currentVersion
eSIM = ".sim"
ePTL = ".ptl"
eJSON = ".json"
eCSV = ".csv"
dirSnippet = "snippets"
dirMenu = "menus"
dirLang = "languages"
dirTable = "tables"
dirParam = "parameters"
dirData = "data"
dirPage = "pages"
dirCon = "contracts"
typeSnippet = "snippets"
typeMenu = "menu"
typeLang = "languages"
typeTable = "tables"
typeParam = "app_params"
typePage = "pages"
typeCon = "contracts"
defaultCondition = "ContractConditions(\"MainCondition\")"
defaultMenu = "default_menu"
defaultPermission = "{\"insert\":\"true\",\"update\":\"true\",\"new_column\":\"true\"}"
configName = "config.json"
separator = string(os.PathSeparator)
structFileName = "struct.dot"
helpMsg = "please choose directory for packing, example:\n ap dirfiles" + separator + "\nor file to unpacking, example:\n app-tool file.json"
)
type configFile struct {
Name string `json:"name,omitempty"`
Conditions string `json:"conditions,omitempty"`
Snippets []importConf `json:"snippets"`
Contracts []importConf `json:"contracts"`
Menus []importConf `json:"menus"`
Pages []importConf `json:"pages"`
Tables []importConf `json:"tables"`
Params []importConf `json:"parameters"`
}
type exportFile struct {
Name string `json:"name,omitempty"`
Conditions string `json:"conditions,omitempty"`
Snippets []importStruct `json:"snippets"`
Contracts []importStruct `json:"contracts"`
Data []dataStruct `json:"data"`
Languages []importStruct `json:"languages"`
Menus []importStruct `json:"menus"`
Pages []importStruct `json:"pages"`
Parameters []importStruct `json:"parameters"`
Tables []importStruct `json:"tables"`
}
func (e *exportFile) cleaning() {
for i := range e.Snippets {
e.Snippets[i].Type = ""
}
for i := range e.Contracts {
e.Contracts[i].Type = ""
}
for i := range e.Languages {
e.Languages[i].Type = ""
}
for i := range e.Menus {
e.Menus[i].Type = ""
}
for i := range e.Pages {
e.Pages[i].Type = ""
}
for i := range e.Parameters {
e.Parameters[i].Type = ""
}
for i := range e.Tables {
e.Tables[i].Type = ""
}
}
type importFile struct {
Snippets []commonStruct `json:"snippets"`
Contracts []commonStruct `json:"contracts"`
Data []dataStruct `json:"data"`
Languages []commonStruct `json:"languages"`
Menus []commonStruct `json:"menus"`
Pages []commonStruct `json:"pages"`
Parameters []commonStruct `json:"parameters"`
Tables []commonStruct `json:"tables"`
Name string `json:"name,omitempty"`
}
func (item *importStruct) dir() string {
if !strings.HasSuffix(item.Type, "s") {
return item.Type + "s"
}
return item.Type
}
func (item *importStruct) fullName() string {
return item.Name + item.ext()
}
func (item *importStruct) ext() string {
switch item.Type {
case typeSnippet:
return ePTL
case typeMenu:
return ePTL
case typePage:
return ePTL
case typeParam:
return eCSV
case typeCon:
return eSIM
default:
return eJSON
}
}
type dataFile struct {
Name string `json:"name"`
Conditions string `json:"conditions,omitempty"`
Data []importStruct `json:"data"`
}
type dataConf struct {
Name string `json:"name"`
Conditions string `json:"conditions,omitempty"`
Data []importConf `json:"data"`
}
type importStruct struct {
FullPath string `json:",omitempty"`
Name string `json:",omitempty"`
Confirmation string `json:",omitempty"`
Conditions string `json:",omitempty"`
Value string `json:",omitempty"`
Trans string `json:",omitempty"`
Menu string `json:",omitempty"`
Columns string `json:",omitempty"`
Permissions string `json:",omitempty"`
Type string `json:",omitempty"`
}
type importConf struct {
Name string `json:",omitempty"`
Confirmation string `json:",omitempty"`
Conditions string `json:",omitempty"`
Menu string `json:",omitempty"`
Permissions string `json:",omitempty"`
Type string `json:",omitempty"`
}
type commonStruct struct {
Name string
Value string
Conditions string
Trans string
Columns string
Table string
}
type testFormatStruct struct {
Name string `json:"name,omitempty"`
Conditions string `json:"conditions,omitempty"`
Snippets []importStruct `json:"snippets,omitempty"`
Contracts []importStruct `json:"contracts,omitempty"`
Languages []importStruct `json:"languages,omitempty"`
Menus []importStruct `json:"menus,omitempty"`
Pages []importStruct `json:"pages,omitempty"`
Parameters []importStruct `json:"parameters,omitempty"`
Tables []importStruct `json:"tables,omitempty"`
}
func (t *testFormatStruct) len() (l int) {
if t.Name != "" {
l++
}
if t.Snippets != nil {
l++
}
if t.Contracts != nil {
l++
}
if t.Languages != nil {
l++
}
if t.Menus != nil {
l++
}
if t.Pages != nil {
l++
}
if t.Parameters != nil {
l++
}
if t.Tables != nil {
l++
}
return l
}
type dataStruct struct {
Table string
Columns []string
Data [][]string
}
type graphStruct struct {
Name string
Value string
Group string
Path string
Dir string
FontColor string
Color string
EdgeLabel string
}