mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Move ObjectDP/SliceDP into own fiels and run TPTests at the end of integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
610483f954
commit
1fc6eff86e
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build integration
|
||||
// +build offline
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
|
||||
@@ -19,9 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -36,7 +34,7 @@ type DataProvider interface {
|
||||
RemoteHost() net.Addr
|
||||
}
|
||||
|
||||
func GetDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) {
|
||||
func DPDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) {
|
||||
if strings.HasPrefix(dnVal, utils.DynamicDataPrefix) {
|
||||
dnVal = strings.TrimPrefix(dnVal, utils.DynamicDataPrefix)
|
||||
return dP.FieldAsInterface(strings.Split(dnVal, utils.NestingSep))
|
||||
@@ -44,174 +42,10 @@ func GetDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) {
|
||||
return utils.StringToInterface(dnVal), nil
|
||||
}
|
||||
|
||||
func GetDynamicString(dnVal string, dP DataProvider) (string, error) {
|
||||
func DPDynamicString(dnVal string, dP DataProvider) (string, error) {
|
||||
if strings.HasPrefix(dnVal, utils.DynamicDataPrefix) {
|
||||
dnVal = strings.TrimPrefix(dnVal, utils.DynamicDataPrefix)
|
||||
return dP.FieldAsString(strings.Split(dnVal, utils.NestingSep))
|
||||
}
|
||||
return dnVal, nil
|
||||
}
|
||||
|
||||
//NewObjectDP constructs a DataProvider
|
||||
func NewObjectDP(obj interface{}) (dP DataProvider) {
|
||||
dP = &ObjectDP{obj: obj, cache: make(map[string]interface{})}
|
||||
return
|
||||
}
|
||||
|
||||
type ObjectDP struct {
|
||||
obj interface{}
|
||||
cache map[string]interface{}
|
||||
}
|
||||
|
||||
func (objDp *ObjectDP) setCache(path string, val interface{}) {
|
||||
objDp.cache[path] = val
|
||||
}
|
||||
|
||||
func (objDp *ObjectDP) getCache(path string) (val interface{}, has bool) {
|
||||
val, has = objDp.cache[path]
|
||||
return
|
||||
}
|
||||
|
||||
// String is part of engine.DataProvider interface
|
||||
// when called, it will display the already parsed values out of cache
|
||||
func (objDP *ObjectDP) String() string {
|
||||
return utils.ToJSON(objDP.obj)
|
||||
}
|
||||
|
||||
// FieldAsInterface is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err error) {
|
||||
// []string{ BalanceMap *monetary[0] Value }
|
||||
var has bool
|
||||
if data, has = objDP.getCache(strings.Join(fldPath, utils.NestingSep)); has {
|
||||
return
|
||||
}
|
||||
|
||||
var prevFld string
|
||||
for _, fld := range fldPath {
|
||||
var slctrStr string
|
||||
if splt := strings.Split(fld, utils.IdxStart); len(splt) != 1 { // check if we have selector
|
||||
fld = splt[0]
|
||||
if splt[1][len(splt[1])-1:] != utils.IdxEnd {
|
||||
return nil, fmt.Errorf("filter rule <%s> needs to end in ]", splt[1])
|
||||
}
|
||||
slctrStr = splt[1][:len(splt[1])-1] // also strip the last ]
|
||||
}
|
||||
if prevFld == utils.EmptyString {
|
||||
prevFld += fld
|
||||
} else {
|
||||
prevFld += utils.NestingSep + fld
|
||||
}
|
||||
|
||||
// check if we take the current path from cache
|
||||
if data, has = objDP.getCache(prevFld); !has {
|
||||
if data, err = utils.ReflectFieldMethodInterface(objDP.obj, fld); err != nil { // take the object the field for current path
|
||||
// in case of error set nil for the current path and return err
|
||||
objDP.setCache(prevFld, nil)
|
||||
return nil, err
|
||||
}
|
||||
// add the current field in prevFld so we can set in cache the full path with it's data
|
||||
objDP.setCache(prevFld, data)
|
||||
}
|
||||
|
||||
// change the obj to be the current data and continue the processing
|
||||
objDP.obj = data
|
||||
if slctrStr != utils.EmptyString { //we have selector so we need to do an aditional get
|
||||
prevFld += utils.IdxStart + slctrStr + utils.IdxEnd
|
||||
// check if we take the current path from cache
|
||||
if data, has = objDP.getCache(prevFld); !has {
|
||||
if data, err = utils.ReflectFieldMethodInterface(objDP.obj, slctrStr); err != nil { // take the object the field for current path
|
||||
// in case of error set nil for the current path and return err
|
||||
objDP.setCache(prevFld, nil)
|
||||
return nil, err
|
||||
}
|
||||
// add the current field in prevFld so we can set in cache the full path with it's data
|
||||
objDP.setCache(prevFld, data)
|
||||
}
|
||||
// change the obj to be the current data and continue the processing
|
||||
objDP.obj = data
|
||||
}
|
||||
|
||||
}
|
||||
//add in cache the initial path
|
||||
objDP.setCache(strings.Join(fldPath, utils.NestingSep), data)
|
||||
return
|
||||
}
|
||||
|
||||
// FieldAsString is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) FieldAsString(fldPath []string) (data string, err error) {
|
||||
var valIface interface{}
|
||||
valIface, err = objDP.FieldAsInterface(fldPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return utils.IfaceAsString(valIface), nil
|
||||
}
|
||||
|
||||
// AsNavigableMap is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) AsNavigableMap([]*FCTemplate) (
|
||||
nm *NavigableMap, err error) {
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// RemoteHost is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) RemoteHost() net.Addr {
|
||||
return utils.LocalAddr()
|
||||
}
|
||||
|
||||
// NewSliceDP constructs a DataProvider
|
||||
func NewSliceDP(record []string) (dP DataProvider) {
|
||||
dP = &SliceDP{req: record, cache: NewNavigableMap(nil)}
|
||||
return
|
||||
}
|
||||
|
||||
// SliceDP implements engine.DataProvider so we can pass it to filters
|
||||
type SliceDP struct {
|
||||
req []string
|
||||
cache *NavigableMap
|
||||
}
|
||||
|
||||
// String is part of engine.DataProvider interface
|
||||
// when called, it will display the already parsed values out of cache
|
||||
func (cP *SliceDP) String() string {
|
||||
return utils.ToJSON(cP)
|
||||
}
|
||||
|
||||
// FieldAsInterface is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) FieldAsInterface(fldPath []string) (data interface{}, err error) {
|
||||
if len(fldPath) != 1 {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
if data, err = cP.cache.FieldAsInterface(fldPath); err == nil ||
|
||||
err != utils.ErrNotFound { // item found in cache
|
||||
return
|
||||
}
|
||||
err = nil // cancel previous err
|
||||
if cfgFieldIdx, err := strconv.Atoi(fldPath[0]); err != nil || len(cP.req) <= cfgFieldIdx {
|
||||
return nil, fmt.Errorf("Ignoring record: %v with error : %+v", cP.req, err)
|
||||
} else {
|
||||
data = cP.req[cfgFieldIdx]
|
||||
}
|
||||
cP.cache.Set(fldPath, data, false, false)
|
||||
return
|
||||
}
|
||||
|
||||
// FieldAsString is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) FieldAsString(fldPath []string) (data string, err error) {
|
||||
var valIface interface{}
|
||||
valIface, err = cP.FieldAsInterface(fldPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return utils.IfaceAsString(valIface), nil
|
||||
}
|
||||
|
||||
// AsNavigableMap is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) AsNavigableMap([]*FCTemplate) (
|
||||
nm *NavigableMap, err error) {
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// RemoteHost is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) RemoteHost() net.Addr {
|
||||
return utils.LocalAddr()
|
||||
}
|
||||
|
||||
133
config/objdp.go
Normal file
133
config/objdp.go
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
//NewObjectDP constructs a DataProvider
|
||||
func NewObjectDP(obj interface{}) (dP DataProvider) {
|
||||
dP = &ObjectDP{obj: obj, cache: make(map[string]interface{})}
|
||||
return
|
||||
}
|
||||
|
||||
type ObjectDP struct {
|
||||
obj interface{}
|
||||
cache map[string]interface{}
|
||||
}
|
||||
|
||||
func (objDp *ObjectDP) setCache(path string, val interface{}) {
|
||||
objDp.cache[path] = val
|
||||
}
|
||||
|
||||
func (objDp *ObjectDP) getCache(path string) (val interface{}, has bool) {
|
||||
val, has = objDp.cache[path]
|
||||
return
|
||||
}
|
||||
|
||||
// String is part of engine.DataProvider interface
|
||||
// when called, it will display the already parsed values out of cache
|
||||
func (objDP *ObjectDP) String() string {
|
||||
return utils.ToJSON(objDP.obj)
|
||||
}
|
||||
|
||||
// FieldAsInterface is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err error) {
|
||||
// []string{ BalanceMap *monetary[0] Value }
|
||||
var has bool
|
||||
if data, has = objDP.getCache(strings.Join(fldPath, utils.NestingSep)); has {
|
||||
return
|
||||
}
|
||||
|
||||
var prevFld string
|
||||
for _, fld := range fldPath {
|
||||
var slctrStr string
|
||||
if splt := strings.Split(fld, utils.IdxStart); len(splt) != 1 { // check if we have selector
|
||||
fld = splt[0]
|
||||
if splt[1][len(splt[1])-1:] != utils.IdxEnd {
|
||||
return nil, fmt.Errorf("filter rule <%s> needs to end in ]", splt[1])
|
||||
}
|
||||
slctrStr = splt[1][:len(splt[1])-1] // also strip the last ]
|
||||
}
|
||||
if prevFld == utils.EmptyString {
|
||||
prevFld += fld
|
||||
} else {
|
||||
prevFld += utils.NestingSep + fld
|
||||
}
|
||||
|
||||
// check if we take the current path from cache
|
||||
if data, has = objDP.getCache(prevFld); !has {
|
||||
if data, err = utils.ReflectFieldMethodInterface(objDP.obj, fld); err != nil { // take the object the field for current path
|
||||
// in case of error set nil for the current path and return err
|
||||
objDP.setCache(prevFld, nil)
|
||||
return nil, err
|
||||
}
|
||||
// add the current field in prevFld so we can set in cache the full path with it's data
|
||||
objDP.setCache(prevFld, data)
|
||||
}
|
||||
|
||||
// change the obj to be the current data and continue the processing
|
||||
objDP.obj = data
|
||||
if slctrStr != utils.EmptyString { //we have selector so we need to do an aditional get
|
||||
prevFld += utils.IdxStart + slctrStr + utils.IdxEnd
|
||||
// check if we take the current path from cache
|
||||
if data, has = objDP.getCache(prevFld); !has {
|
||||
if data, err = utils.ReflectFieldMethodInterface(objDP.obj, slctrStr); err != nil { // take the object the field for current path
|
||||
// in case of error set nil for the current path and return err
|
||||
objDP.setCache(prevFld, nil)
|
||||
return nil, err
|
||||
}
|
||||
// add the current field in prevFld so we can set in cache the full path with it's data
|
||||
objDP.setCache(prevFld, data)
|
||||
}
|
||||
// change the obj to be the current data and continue the processing
|
||||
objDP.obj = data
|
||||
}
|
||||
|
||||
}
|
||||
//add in cache the initial path
|
||||
objDP.setCache(strings.Join(fldPath, utils.NestingSep), data)
|
||||
return
|
||||
}
|
||||
|
||||
// FieldAsString is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) FieldAsString(fldPath []string) (data string, err error) {
|
||||
var valIface interface{}
|
||||
valIface, err = objDP.FieldAsInterface(fldPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return utils.IfaceAsString(valIface), nil
|
||||
}
|
||||
|
||||
// AsNavigableMap is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) AsNavigableMap([]*FCTemplate) (
|
||||
nm *NavigableMap, err error) {
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// RemoteHost is part of engine.DataProvider interface
|
||||
func (objDP *ObjectDP) RemoteHost() net.Addr {
|
||||
return utils.LocalAddr()
|
||||
}
|
||||
85
config/slicedp.go
Normal file
85
config/slicedp.go
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// NewSliceDP constructs a DataProvider
|
||||
func NewSliceDP(record []string) (dP DataProvider) {
|
||||
dP = &SliceDP{req: record, cache: NewNavigableMap(nil)}
|
||||
return
|
||||
}
|
||||
|
||||
// SliceDP implements engine.DataProvider so we can pass it to filters
|
||||
type SliceDP struct {
|
||||
req []string
|
||||
cache *NavigableMap
|
||||
}
|
||||
|
||||
// String is part of engine.DataProvider interface
|
||||
// when called, it will display the already parsed values out of cache
|
||||
func (cP *SliceDP) String() string {
|
||||
return utils.ToJSON(cP)
|
||||
}
|
||||
|
||||
// FieldAsInterface is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) FieldAsInterface(fldPath []string) (data interface{}, err error) {
|
||||
if len(fldPath) != 1 {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
if data, err = cP.cache.FieldAsInterface(fldPath); err == nil ||
|
||||
err != utils.ErrNotFound { // item found in cache
|
||||
return
|
||||
}
|
||||
err = nil // cancel previous err
|
||||
if cfgFieldIdx, err := strconv.Atoi(fldPath[0]); err != nil || len(cP.req) <= cfgFieldIdx {
|
||||
return nil, fmt.Errorf("Ignoring record: %v with error : %+v", cP.req, err)
|
||||
} else {
|
||||
data = cP.req[cfgFieldIdx]
|
||||
}
|
||||
cP.cache.Set(fldPath, data, false, false)
|
||||
return
|
||||
}
|
||||
|
||||
// FieldAsString is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) FieldAsString(fldPath []string) (data string, err error) {
|
||||
var valIface interface{}
|
||||
valIface, err = cP.FieldAsInterface(fldPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return utils.IfaceAsString(valIface), nil
|
||||
}
|
||||
|
||||
// AsNavigableMap is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) AsNavigableMap([]*FCTemplate) (
|
||||
nm *NavigableMap, err error) {
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
// RemoteHost is part of engine.DataProvider interface
|
||||
func (cP *SliceDP) RemoteHost() net.Addr {
|
||||
return utils.LocalAddr()
|
||||
}
|
||||
@@ -332,7 +332,7 @@ func (fltr *FilterRule) Pass(fieldNameDP config.DataProvider,
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP)
|
||||
strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -340,7 +340,7 @@ func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP
|
||||
return false, err
|
||||
}
|
||||
for i, val := range fltr.Values {
|
||||
sval, err := config.GetDynamicString(val, fieldValuesDP[i])
|
||||
sval, err := config.DPDynamicString(val, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -352,7 +352,7 @@ func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passExists(fielNameDP config.DataProvider) (bool, error) {
|
||||
_, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
_, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -363,7 +363,7 @@ func (fltr *FilterRule) passExists(fielNameDP config.DataProvider) (bool, error)
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passEmpty(fielNameDP config.DataProvider) (bool, error) {
|
||||
val, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
val, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return true, nil
|
||||
@@ -393,7 +393,7 @@ func (fltr *FilterRule) passEmpty(fielNameDP config.DataProvider) (bool, error)
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP)
|
||||
strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -401,7 +401,7 @@ func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldVa
|
||||
return false, err
|
||||
}
|
||||
for i, prfx := range fltr.Values {
|
||||
prfx, err := config.GetDynamicString(prfx, fieldValuesDP[i])
|
||||
prfx, err := config.DPDynamicString(prfx, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -413,7 +413,7 @@ func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldVa
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passStringSuffix(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP)
|
||||
strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -421,7 +421,7 @@ func (fltr *FilterRule) passStringSuffix(fielNameDP config.DataProvider, fieldVa
|
||||
return false, err
|
||||
}
|
||||
for i, prfx := range fltr.Values {
|
||||
prfx, err := config.GetDynamicString(prfx, fieldValuesDP[i])
|
||||
prfx, err := config.DPDynamicString(prfx, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -438,7 +438,7 @@ func (fltr *FilterRule) passTimings(fielNameDP config.DataProvider, fieldValuesD
|
||||
}
|
||||
|
||||
func (fltr *FilterRule) passDestinations(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
dst, err := config.GetDynamicString(fltr.FieldName, fielNameDP)
|
||||
dst, err := config.DPDynamicString(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -449,7 +449,7 @@ func (fltr *FilterRule) passDestinations(fielNameDP config.DataProvider, fieldVa
|
||||
if destIDs, err := dm.DataDB().GetReverseDestination(p, false, utils.NonTransactional); err == nil {
|
||||
for _, dID := range destIDs {
|
||||
for i, valDstID := range fltr.Values {
|
||||
valDstID, err := config.GetDynamicString(valDstID, fieldValuesDP[i])
|
||||
valDstID, err := config.DPDynamicString(valDstID, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -515,7 +515,7 @@ func (fltr *FilterRule) passRSR(fieldValuesDP []config.DataProvider) (bool, erro
|
||||
// }
|
||||
|
||||
func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
fldIf, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
fldIf, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -531,7 +531,7 @@ func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldVal
|
||||
orEqual = true
|
||||
}
|
||||
for i, val := range fltr.Values {
|
||||
sval, err := config.GetDynamicInterface(val, fieldValuesDP[i])
|
||||
sval, err := config.DPDynamicInterface(val, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -580,7 +580,7 @@ func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldVal
|
||||
// }
|
||||
|
||||
func (fltr *FilterRule) passEqualTo(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) {
|
||||
fldIf, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
fldIf, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
return false, nil
|
||||
@@ -591,7 +591,7 @@ func (fltr *FilterRule) passEqualTo(fielNameDP config.DataProvider, fieldValuesD
|
||||
fldIf = utils.StringToInterface(fldStr)
|
||||
}
|
||||
for i, val := range fltr.Values {
|
||||
sval, err := config.GetDynamicInterface(val, fieldValuesDP[i])
|
||||
sval, err := config.DPDynamicInterface(val, fieldValuesDP[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ dis=$?
|
||||
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration'
|
||||
go test github.com/cgrates/cgrates/loaders -tags=integration
|
||||
lds=$?
|
||||
echo 'go test github.com/cgrates/cgrates/ers -tags=integration'
|
||||
go test github.com/cgrates/cgrates/ers -tags=integration
|
||||
ers=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=offline
|
||||
offline=$?
|
||||
|
||||
exit $gen && $ap1 && $ap2 && $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers
|
||||
exit $gen && $ap1 && $ap2 && $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers && offline
|
||||
|
||||
Reference in New Issue
Block a user