Commit 18fcd6d6bfa31d201c800adb6a1177b34ebb1c46

Authored by Marko Tikvić
1 parent cacf57bd4a
Exists in master

merged with util package

default_values.go
1   -package util
  1 +package webutility
2 2  
3 3 // IntOrDefault ...
4 4 func IntOrDefault(v *int) int {
... ...
1   -package util
  1 +package webutility
2 2  
3 3 // Diff ...
4 4 func Diff(old, new []int64) (added, removed []int64) {
... ...
1   -package util
  1 +package webutility
2 2  
3 3 import (
4 4 "bytes"
... ...
1   -package util
  1 +package webutility
2 2  
3 3 import (
4 4 "fmt"
... ...
1   -package util
  1 +package webutility
2 2  
3 3 import (
4 4 "database/sql"
... ...
... ... @@ -12,7 +12,6 @@ import (
12 12 "time"
13 13  
14 14 "git.to-net.rs/marko.tikvic/gologger"
15   - "git.to-net.rs/marko.tikvic/util"
16 15 )
17 16  
18 17 var (
... ... @@ -24,9 +23,9 @@ var (
24 23 metadataDB *sql.DB
25 24 activeProject string
26 25  
27   - inited bool
28   - driver string
29   - logger *gologger.Logger
  26 + inited bool
  27 + metaDriver string
  28 + logger *gologger.Logger
30 29 )
31 30  
32 31 // LangMap ...
... ... @@ -140,7 +139,7 @@ func InitPayloadsMetadata(drv string, db *sql.DB, project string) error {
140 139 return err
141 140 }
142 141  
143   - driver = drv
  142 + metaDriver = drv
144 143 metadataDB = db
145 144 activeProject = project
146 145  
... ... @@ -209,13 +208,13 @@ func UpdateEntityModels(command string) (total, upd, add int, err error) {
209 208 }
210 209  
211 210 var uStmt *sql.Stmt
212   - if driver == "ora" {
  211 + if metaDriver == "ora" {
213 212 uStmt, err = metadataDB.Prepare("update entities set entity_model = :1 where entity_type = :2")
214 213 if err != nil {
215 214 logger.Trace(err.Error())
216 215 return
217 216 }
218   - } else if driver == "mysql" {
  217 + } else if metaDriver == "mysql" {
219 218 uStmt, err = metadataDB.Prepare("update entities set entity_model = ? where entity_type = ?")
220 219 if err != nil {
221 220 logger.Trace(err.Error())
... ... @@ -233,13 +232,13 @@ func UpdateEntityModels(command string) (total, upd, add int, err error) {
233 232  
234 233 blankPayload, _ := json.Marshal(Payload{})
235 234 var iStmt *sql.Stmt
236   - if driver == "ora" {
  235 + if metaDriver == "ora" {
237 236 iStmt, err = metadataDB.Prepare("insert into entities(projekat, metadata, entity_type, entity_model) values(:1, :2, :3, :4)")
238 237 if err != nil {
239 238 logger.Trace(err.Error())
240 239 return
241 240 }
242   - } else if driver == "mysql" {
  241 + } else if metaDriver == "mysql" {
243 242 iStmt, err = metadataDB.Prepare("insert into entities(projekat, metadata, entity_type, entity_model) values(?, ?, ?, ?)")
244 243 if err != nil {
245 244 logger.Trace(err.Error())
... ... @@ -303,7 +302,7 @@ func initMetadata(project string) error {
303 302 //
304 303 // TODO(marko): Currently supports only one hardcoded language...
305 304 func LoadMetadataFromFile(path string) error {
306   - lines, err := util.ReadFileLines(path)
  305 + lines, err := ReadFileLines(path)
307 306 if err != nil {
308 307 return err
309 308 }
... ... @@ -317,7 +316,7 @@ func LoadMetadataFromFile(path string) error {
317 316 continue
318 317 }
319 318  
320   - if util.IsWrappedWith(l, "[", "]") {
  319 + if IsWrappedWith(l, "[", "]") {
321 320 name = strings.Trim(l, "[]")
322 321 p := Payload{}
323 322 p.addLang("sr", make(map[string]string))
... ...
string_sanitisation.go
1 1 package webutility
2 2  
3   -import "git.to-net.rs/marko.tikvic/util"
4   -
5 3 const patern = "\"';&*<>=\\`:"
6 4  
7 5 // SanitiseString removes characters from s found in patern and returns new modified string.
8 6 func SanitiseString(s string) string {
9   - return util.ReplaceAny(s, patern, "")
  7 + return ReplaceAny(s, patern, "")
10 8 }
... ...
1   -package util
  1 +package webutility
2 2  
3 3 import (
4 4 "fmt"
... ...