mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
apier compilation fixes
This commit is contained in:
@@ -189,8 +189,8 @@ func (self *ApierV1) LoadDestination(attrs AttrLoadDestination, reply *string) e
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
if loaded, err := dbReader.LoadDestinationByTag(attrs.DestinationId); err != nil {
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if loaded, err := dbReader.LoadDestinationsFiltered(attrs.DestinationId); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if !loaded {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
@@ -213,7 +213,7 @@ func (self *ApierV1) LoadDerivedChargers(attrs utils.TPDerivedChargers, reply *s
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if err := dbReader.LoadDerivedChargersFiltered(&attrs, true); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
@@ -240,8 +240,8 @@ func (self *ApierV1) LoadRatingPlan(attrs AttrLoadRatingPlan, reply *string) err
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
if loaded, err := dbReader.LoadRatingPlanByTag(attrs.RatingPlanId); err != nil {
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if loaded, err := dbReader.LoadRatingPlansFiltered(attrs.RatingPlanId); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if !loaded {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
@@ -264,8 +264,8 @@ func (self *ApierV1) LoadRatingProfile(attrs utils.TPRatingProfile, reply *strin
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
if err := dbReader.LoadRatingProfileFiltered(&attrs); err != nil {
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if err := dbReader.LoadRatingProfilesFiltered(&attrs); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
//Automatic cache of the newly inserted rating profile
|
||||
@@ -291,8 +291,8 @@ func (self *ApierV1) LoadSharedGroup(attrs AttrLoadSharedGroup, reply *string) e
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
if err := dbReader.LoadSharedGroupByTag(attrs.SharedGroupId, true); err != nil {
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if err := dbReader.LoadSharedGroupsFiltered(attrs.SharedGroupId, true); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
//Automatic cache of the newly inserted rating plan
|
||||
@@ -318,8 +318,8 @@ func (self *ApierV1) LoadCdrStats(attrs AttrLoadCdrStats, reply *string) error {
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
if err := dbReader.LoadCdrStatsByTag(attrs.CdrStatsId, true); err != nil {
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if err := dbReader.LoadCdrStatsFiltered(attrs.CdrStatsId, true); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
*reply = OK
|
||||
@@ -338,12 +338,12 @@ func (self *ApierV1) LoadTariffPlanFromStorDb(attrs AttrLoadTpFromStorDb, reply
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if err := dbReader.LoadAll(); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
if attrs.Validate {
|
||||
if !dbReader.IsDataValid() {
|
||||
if !dbReader.IsValid() {
|
||||
*reply = OK
|
||||
return errors.New("invalid data")
|
||||
}
|
||||
@@ -805,7 +805,7 @@ func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *str
|
||||
if len(attrs.TPid) == 0 {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_MANDATORY_IE_MISSING, "TPid")
|
||||
}
|
||||
dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
|
||||
dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid)
|
||||
if _, err := engine.AccLock.Guard(func() (interface{}, error) {
|
||||
if err := dbReader.LoadAccountActionsFiltered(&attrs); err != nil {
|
||||
return 0, err
|
||||
@@ -970,7 +970,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
|
||||
} else if !fi.IsDir() {
|
||||
return errors.New(utils.ERR_INVALID_PATH)
|
||||
}
|
||||
loader := engine.NewFileCSVReader(self.RatingDb, self.AccountDb, utils.CSV_SEP,
|
||||
loader := engine.NewTpReader(self.RatingDb, self.AccountDb, engine.NewFileCSVStorage(utils.CSV_SEP,
|
||||
path.Join(attrs.FolderPath, utils.DESTINATIONS_CSV),
|
||||
path.Join(attrs.FolderPath, utils.TIMINGS_CSV),
|
||||
path.Join(attrs.FolderPath, utils.RATES_CSV),
|
||||
@@ -984,7 +984,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
|
||||
path.Join(attrs.FolderPath, utils.ACTION_TRIGGERS_CSV),
|
||||
path.Join(attrs.FolderPath, utils.ACCOUNT_ACTIONS_CSV),
|
||||
path.Join(attrs.FolderPath, utils.DERIVED_CHARGERS_CSV),
|
||||
path.Join(attrs.FolderPath, utils.CDR_STATS_CSV))
|
||||
path.Join(attrs.FolderPath, utils.CDR_STATS_CSV)), "")
|
||||
if err := loader.LoadAll(); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
@@ -994,7 +994,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
|
||||
}
|
||||
|
||||
if attrs.Validate {
|
||||
if !loader.IsDataValid() {
|
||||
if !loader.IsValid() {
|
||||
*reply = OK
|
||||
return errors.New("invalid data")
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ type AttrGetTPIds struct {
|
||||
|
||||
// Queries tarrif plan identities gathered from all tables.
|
||||
func (self *ApierV1) GetTPIds(attrs AttrGetTPIds, reply *[]string) error {
|
||||
if ids, err := self.StorDb.GetTPIds(); err != nil {
|
||||
if ids, err := self.StorDb.GetTpIds(); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
|
||||
@@ -1076,7 +1076,6 @@ func (self *SQLStorage) GetTpDestinations(tpid, tag string) ([]TpDestination, er
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTpRates(tpid, tag string) ([]TpRate, error) {
|
||||
rts := make(map[string]*utils.TPRate)
|
||||
var tpRates []TpRate
|
||||
q := self.db.Where("tpid = ?", tpid).Order("id")
|
||||
if len(tag) != 0 {
|
||||
|
||||
@@ -60,6 +60,17 @@ func NewTpReader(rs RatingStorage, as AccountingStorage, lr LoadReader, tpid str
|
||||
}
|
||||
}
|
||||
|
||||
func (tpr *TpReader) LoadDestinationsFiltered(tag string) (bool, error) {
|
||||
tpDests, err := tpr.lr.GetTpDestinations(tpr.tpid, tag)
|
||||
|
||||
dest := &Destination{Id: tag}
|
||||
for _, tpDest := range tpDests {
|
||||
dest.AddPrefix(tpDest.Prefix)
|
||||
}
|
||||
dataStorage.SetDestination(dest)
|
||||
return len(tpDests) > 0, err
|
||||
}
|
||||
|
||||
func (tpr *TpReader) LoadDestinations() (err error) {
|
||||
tps, err := tpr.lr.GetTpDestinations(tpr.tpid, "")
|
||||
if err != nil {
|
||||
@@ -121,7 +132,7 @@ func (tpr *TpReader) LoadDestinationRates() (err error) {
|
||||
}
|
||||
|
||||
// Returns true, nil in case of load success, false, nil in case of RatingPlan not found ratingStorage
|
||||
func (tpr *TpReader) LoadRatingPlanFiltered(tag string) (bool, error) {
|
||||
func (tpr *TpReader) LoadRatingPlansFiltered(tag string) (bool, error) {
|
||||
mpRpls, err := tpr.lr.GetTpRatingPlans(tpr.tpid, tag, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -229,7 +240,7 @@ func (tpr *TpReader) LoadRatingPlans() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tpr *TpReader) LoadRatingProfileFiltered(qriedRpf *utils.TPRatingProfile) error {
|
||||
func (tpr *TpReader) LoadRatingProfilesFiltered(qriedRpf *utils.TPRatingProfile) error {
|
||||
var resultRatingProfile *RatingProfile
|
||||
mpTpRpfs, err := tpr.lr.GetTpRatingProfiles(qriedRpf)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user