Remove pathPrfx from fwvDP

This commit is contained in:
TeoV
2020-01-23 11:02:07 +02:00
parent f74df27ddd
commit 923012a785
2 changed files with 7 additions and 15 deletions

View File

@@ -28,17 +28,15 @@ import (
)
// NewfwvProvider constructs a DataProvider
func NewFWVProvider(record, pathPrfx string) (dP DataProvider) {
dP = &FWVProvider{req: record, cache: NewNavigableMap(nil), pathPrfx: pathPrfx}
func NewFWVProvider(record string) (dP DataProvider) {
dP = &FWVProvider{req: record, cache: NewNavigableMap(nil)}
return
}
// fwvProvider implements engine.DataProvider so we can pass it to filters
type FWVProvider 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
@@ -53,12 +51,6 @@ func (fP *FWVProvider) FieldAsInterface(fldPath []string) (data interface{}, err
return
}
fwvIdx := fldPath[0]
if len(fldPath) == 2 {
fwvIdx = fldPath[1]
}
if fP.pathPrfx != utils.EmptyString && (fldPath[0] != fP.pathPrfx || len(fldPath) < 2) {
return "", utils.ErrPrefixNotFound(strings.Join(fldPath, utils.NestingSep))
}
if data, err = fP.cache.FieldAsInterface(fldPath); err == nil ||
err != utils.ErrNotFound { // item found in cache
return

View File

@@ -169,7 +169,7 @@ func (rdr *FWVFileER) processFile(fPath, fName string) (err error) {
rowNr++ // increment the rowNr after checking if it's not the end of file
record := string(buf)
agReq := agents.NewAgentRequest(
config.NewFWVProvider(record, utils.EmptyString), reqVars,
config.NewFWVProvider(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,
@@ -251,7 +251,7 @@ func (rdr *FWVFileER) processTrailer(file *os.File, rowNr, evsPosted int, absPat
record := string(buf)
reqVars := make(map[string]interface{})
agReq := agents.NewAgentRequest(
config.NewFWVProvider(record, utils.EmptyString), reqVars,
config.NewFWVProvider(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,
@@ -288,7 +288,7 @@ func (rdr *FWVFileER) processHeader(file *os.File, rowNr, evsPosted int, absPath
func (rdr *FWVFileER) createHeaderMap(record string, rowNr, evsPosted int, absPath string) (err error) {
reqVars := make(map[string]interface{})
agReq := agents.NewAgentRequest(
config.NewFWVProvider(record, utils.EmptyString), reqVars,
config.NewFWVProvider(record), reqVars,
nil, nil, rdr.Config().Tenant,
rdr.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(rdr.Config().Timezone,