Remove pathPrfx from sliceDP

This commit is contained in:
TeoV
2020-01-23 10:47:32 +02:00
parent 2e8ad3d15c
commit c82c1c4866
4 changed files with 10 additions and 16 deletions

View File

@@ -22,23 +22,20 @@ import (
"fmt"
"net"
"strconv"
"strings"
"github.com/cgrates/cgrates/utils"
)
// NewSliceDP constructs a DataProvider
func NewSliceDP(record []string, pathPrfx string) (dP DataProvider) {
dP = &SliceDP{req: record, cache: NewNavigableMap(nil), pathPrfx: pathPrfx}
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
pathPrfx string // if this comes in path it will be ignored
// pathPrfx should be reviewed once the cdrc is removed
req []string
cache *NavigableMap
}
// String is part of engine.DataProvider interface
@@ -52,13 +49,10 @@ func (cP *SliceDP) FieldAsInterface(fldPath []string) (data interface{}, err err
if len(fldPath) == 0 {
return
}
if len(fldPath) != 1 {
return nil, fmt.Errorf("Invalid fieldPath %+v", fldPath)
}
idx := fldPath[0]
if len(fldPath) == 2 {
idx = fldPath[1]
}
if cP.pathPrfx != utils.EmptyString && (fldPath[0] != cP.pathPrfx || len(fldPath) < 2) {
return "", utils.ErrPrefixNotFound(strings.Join(fldPath, utils.NestingSep))
}
if data, err = cP.cache.FieldAsInterface(fldPath); err == nil ||
err != utils.ErrNotFound { // item found in cache
return

View File

@@ -143,7 +143,7 @@ func (rdr *CSVFileER) processFile(fPath, fName string) (err error) {
}
rowNr++ // increment the rowNr after checking if it's not the end of file
agReq := agents.NewAgentRequest(
config.NewSliceDP(record, utils.EmptyString), reqVars,
config.NewSliceDP(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,

View File

@@ -182,7 +182,7 @@ func (rdr *FlatstoreER) processFile(fPath, fName string) (err error) {
}
rowNr++ // increment the rowNr after checking if it's not the end of file
agReq := agents.NewAgentRequest(
config.NewSliceDP(record, utils.EmptyString), reqVars,
config.NewSliceDP(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,

View File

@@ -158,7 +158,7 @@ func (rdr *PartialCSVFileER) processFile(fPath, fName string) (err error) {
}
rowNr++ // increment the rowNr after checking if it's not the end of file
agReq := agents.NewAgentRequest(
config.NewSliceDP(record, utils.EmptyString), reqVars,
config.NewSliceDP(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,