Adding dataDb checks for destinations and rating plans on csv loader

This commit is contained in:
DanB
2013-11-13 10:04:51 +01:00
parent 13ce865b6f
commit 86bcbac221

View File

@@ -277,7 +277,11 @@ func (csvr *CSVReader) LoadDestinationRates() (err error) {
}
}
if !destinationExists {
return errors.New(fmt.Sprintf("Could not get destination for tag %v", record[1]))
if dbExists, err := csvr.storage.ExistsDestination(record[1]); err != nil {
return err
} else if !dbExists {
return fmt.Errorf("Could not get destination for tag %v", record[1])
}
}
dr := &DestinationRate{
Tag: tag,
@@ -347,7 +351,11 @@ func (csvr *CSVReader) LoadRatingProfiles() (err error) {
}
_, exists := csvr.ratingPlans[record[5]]
if !exists {
return errors.New(fmt.Sprintf("Could not load destination rate timings for tag: %v", record[5]))
if dbExists, err := csvr.storage.ExistsRatingPlan(record[5]); err != nil {
return err
} else if !dbExists {
return errors.New(fmt.Sprintf("Could not load rating plans for tag: %v", record[5]))
}
}
rp.RatingPlanActivations = append(rp.RatingPlanActivations, &RatingPlanActivation{at, record[5]})
if fallbacksubject != "" {