From b8e4c3cfc30647cd0552a1d6e08e1c4f111df23f Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 13 Dec 2017 14:27:18 +0200 Subject: [PATCH] Renaming TPFilte -> TPFilterProfile , TPSupplier -> TPSupplierProfile , TPAttribute -> TPAttributeProfile --- apier/v1/tpattributes.go | 22 ++--- .../mysql/create_tariffplan_tables.sql | 4 +- .../postgres/create_tariffplan_tables.sql | 4 +- data/tariffplans/testtp/Attributes.csv | 6 +- data/tariffplans/tutorial/Attributes.csv | 2 +- engine/attributes.go | 6 +- engine/attributes_it_test.go | 60 ++++++------ engine/filterindexer.go | 2 +- engine/libattributes.go | 36 +++---- engine/loader_csv_test.go | 70 +++++++------- engine/model_helpers.go | 96 +++++++++---------- engine/model_helpers_test.go | 84 ++++++++-------- engine/models.go | 2 +- engine/storage_csv.go | 8 +- engine/storage_interface.go | 12 +-- engine/storage_mongo_stordb.go | 18 ++-- engine/storage_sql.go | 12 +-- engine/tp_reader.go | 18 ++-- utils/apitpdata.go | 26 ++--- 19 files changed, 244 insertions(+), 244 deletions(-) diff --git a/apier/v1/tpattributes.go b/apier/v1/tpattributes.go index 1725c024b..c88cdc761 100644 --- a/apier/v1/tpattributes.go +++ b/apier/v1/tpattributes.go @@ -22,25 +22,25 @@ import ( "github.com/cgrates/cgrates/utils" ) -// Creates a new attribute within a tariff plan -func (self *ApierV1) SetTPAttribute(attrs utils.TPAttribute, reply *string) error { +// Creates a new AttributeProfile within a tariff plan +func (self *ApierV1) SetTPAttributeProfile(attrs utils.TPAttributeProfile, reply *string) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid", "Tenant", "ID"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - if err := self.StorDb.SetTPAttributes([]*utils.TPAttribute{&attrs}); err != nil { + if err := self.StorDb.SetTPAttributes([]*utils.TPAttributeProfile{&attrs}); err != nil { return utils.NewErrServerError(err) } *reply = utils.OK return nil } -type AttrGetTPAttribute struct { +type AttrGetTPAttributeProfile struct { TPid string // Tariff plan id ID string } -// Queries specific Attribute on Tariff plan -func (self *ApierV1) GetTPAttribute(attr AttrGetTPAttribute, reply *utils.TPAttribute) error { +// Queries specific AttributeProfile on Tariff plan +func (self *ApierV1) GetTPAttributeProfile(attr AttrGetTPAttributeProfile, reply *utils.TPAttributeProfile) error { if missing := utils.MissingStructFields(&attr, []string{"TPid", "ID"}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } @@ -55,13 +55,13 @@ func (self *ApierV1) GetTPAttribute(attr AttrGetTPAttribute, reply *utils.TPAttr return nil } -type AttrGetTPAttributeIds struct { +type AttrGetTPAttributeProfileIds struct { TPid string // Tariff plan id utils.Paginator } // Queries attribute identities on specific tariff plan. -func (self *ApierV1) GetTPAttributeIds(attrs AttrGetTPAttributeIds, reply *[]string) error { +func (self *ApierV1) GetTPAttributeProfileIds(attrs AttrGetTPAttributeProfileIds, reply *[]string) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } @@ -75,14 +75,14 @@ func (self *ApierV1) GetTPAttributeIds(attrs AttrGetTPAttributeIds, reply *[]str return nil } -type AttrRemTPAttribute struct { +type AttrRemTPAttributeProfile struct { TPid string // Tariff plan id Tenant string ID string // Attribute id } -// Removes specific Attribute on Tariff plan -func (self *ApierV1) RemTPAttribute(attrs AttrRemTPAttribute, reply *string) error { +// Removes specific AttributeProfile on Tariff plan +func (self *ApierV1) RemTPAttributeProfile(attrs AttrRemTPAttributeProfile, reply *string) error { if missing := utils.MissingStructFields(&attrs, []string{"TPid", "Tenant", "ID"}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index c747479cf..5991bf942 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -535,14 +535,14 @@ CREATE TABLE tp_attributes ( `activation_interval` varchar(64) NOT NULL, `field_name` varchar(64) NOT NULL, `initial` varchar(64) NOT NULL, - `alias` varchar(64) NOT NULL, + `substitute` varchar(64) NOT NULL, `append` BOOLEAN NOT NULL, `weight` decimal(8,2) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), UNIQUE KEY `unique_tp_attributes` (`tpid`,`tenant`, - `id`,`filter_ids`,`field_name`,`initial`,`alias` ) + `id`,`filter_ids`,`field_name`,`initial`,`substitute` ) ); -- diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql index a4fd7911e..5ed3b98f8 100644 --- a/data/storage/postgres/create_tariffplan_tables.sql +++ b/data/storage/postgres/create_tariffplan_tables.sql @@ -525,14 +525,14 @@ CREATE INDEX tp_suppliers_unique ON tp_suppliers ("tpid", "tenant", "id", "activation_interval" varchar(64) NOT NULL, "field_name" varchar(64) NOT NULL, "initial" varchar(64) NOT NULL, - "alias" varchar(64) NOT NULL, + "substitute" varchar(64) NOT NULL, "append" BOOLEAN NOT NULL, "weight" decimal(8,2) NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE ); CREATE INDEX tp_attributes_ids ON tp_attributes (tpid); CREATE INDEX tp_attributes_unique ON tp_attributes ("tpid", "tenant", "id", - "filter_ids","field_name","initial","alias"); + "filter_ids","field_name","initial","substitute"); -- diff --git a/data/tariffplans/testtp/Attributes.csv b/data/tariffplans/testtp/Attributes.csv index 0aaa9758f..fa8b32c23 100644 --- a/data/tariffplans/testtp/Attributes.csv +++ b/data/tariffplans/testtp/Attributes.csv @@ -1,3 +1,3 @@ -#,Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Alias,Append,Weight -cgrates.org,ALS1,con1,FLTR_1,2014-07-29T15:00:00Z,Field1,Initial1,Alias1,true,20 -cgrates.org,ALS1,,,,Field2,Initial2,Alias2,false, +#,Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Substitute,Append,Weight +cgrates.org,ALS1,con1,FLTR_1,2014-07-29T15:00:00Z,Field1,Initial1,Sub1,true,20 +cgrates.org,ALS1,,,,Field2,Initial2,Sub2,false, diff --git a/data/tariffplans/tutorial/Attributes.csv b/data/tariffplans/tutorial/Attributes.csv index 6cf08840e..f48175d5b 100644 --- a/data/tariffplans/tutorial/Attributes.csv +++ b/data/tariffplans/tutorial/Attributes.csv @@ -1,3 +1,3 @@ -#Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Alias,Append,Weight +#Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Substitute,Append,Weight cgrates.org,ATTR_1,*rating,FLTR_ACNT_1007,2014-01-14T00:00:00Z,Account,*any,1001,false,10 cgrates.org,ATTR_1,,,,Subject,*any,1001,true, diff --git a/engine/attributes.go b/engine/attributes.go index 7f6c8a621..e3fed3c11 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -127,11 +127,11 @@ func (alS *AttributeService) processEvent(ev *utils.CGREvent) (rply *AttrSProces return nil, err } rply = &AttrSProcessEventReply{MatchedProfile: attrPrf.ID, CGREvent: ev.Clone()} - for fldName, intialMp := range attrPrf.Substitutes { + for fldName, intialMp := range attrPrf.Attributes { initEvValIf, has := ev.Event[fldName] if !has { // we don't have initial in event, try append if anyInitial, has := intialMp[utils.ANY]; has && anyInitial.Append { - rply.CGREvent.Event[fldName] = anyInitial.Alias + rply.CGREvent.Event[fldName] = anyInitial.Substitute rply.AlteredFields = append(rply.AlteredFields, fldName) } continue @@ -148,7 +148,7 @@ func (alS *AttributeService) processEvent(ev *utils.CGREvent) (rply *AttrSProces attrVal, has = intialMp[utils.ANY] } if has { - rply.CGREvent.Event[fldName] = attrVal.Alias + rply.CGREvent.Event[fldName] = attrVal.Substitute rply.AlteredFields = append(rply.AlteredFields, fldName) } } diff --git a/engine/attributes_it_test.go b/engine/attributes_it_test.go index 5d72f034f..798e350bc 100644 --- a/engine/attributes_it_test.go +++ b/engine/attributes_it_test.go @@ -36,23 +36,23 @@ func TestExternalAttributeProfileAsAttributeProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), }, - Substitutes: []*AttributeSubstitute{ - &AttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + Attributes: []*Attribute{ + &Attribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, }, }, Weight: 20, } - attrMap := make(map[string]map[string]*AttributeSubstitute) - attrMap["FL1"] = make(map[string]*AttributeSubstitute) - attrMap["FL1"]["In1"] = &AttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + attrMap := make(map[string]map[string]*Attribute) + attrMap["FL1"] = make(map[string]*Attribute) + attrMap["FL1"]["In1"] = &Attribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, } expected := &AttributeProfile{ Tenant: "cgrates.org", @@ -63,8 +63,8 @@ func TestExternalAttributeProfileAsAttributeProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), }, - Substitutes: attrMap, - Weight: 20, + Attributes: attrMap, + Weight: 20, } rcv := extAttr.AsAttributeProfile() @@ -74,13 +74,13 @@ func TestExternalAttributeProfileAsAttributeProfile(t *testing.T) { } func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) { - attrMap := make(map[string]map[string]*AttributeSubstitute) - attrMap["FL1"] = make(map[string]*AttributeSubstitute) - attrMap["FL1"]["In1"] = &AttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + attrMap := make(map[string]map[string]*Attribute) + attrMap["FL1"] = make(map[string]*Attribute) + attrMap["FL1"]["In1"] = &Attribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, } attrPrf := &AttributeProfile{ Tenant: "cgrates.org", @@ -91,8 +91,8 @@ func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), }, - Substitutes: attrMap, - Weight: 20, + Attributes: attrMap, + Weight: 20, } expected := &ExternalAttributeProfile{ @@ -104,12 +104,12 @@ func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) { ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(), }, - Substitutes: []*AttributeSubstitute{ - &AttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + Attributes: []*Attribute{ + &Attribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, }, }, Weight: 20, diff --git a/engine/filterindexer.go b/engine/filterindexer.go index 71ade910c..ce9f76e38 100644 --- a/engine/filterindexer.go +++ b/engine/filterindexer.go @@ -105,7 +105,7 @@ func (rfi *ReqFilterIndexer) IndexFilters(itemID string, reqFltrs []*RequestFilt } // IndexFilters parses reqFltrs, adding itemID in the indexes and marks the changed keys in chngdIndxKeys -func (rfi *ReqFilterIndexer) IndexTPFilter(tpFltr *utils.TPFilter, itemID string) { +func (rfi *ReqFilterIndexer) IndexTPFilter(tpFltr *utils.TPFilterProfile, itemID string) { var hasMetaString bool rfi.reveseIndex[itemID] = make(map[string]utils.StringMap) for _, fltr := range tpFltr.Filters { diff --git a/engine/libattributes.go b/engine/libattributes.go index 3746e75ce..d9192d7be 100644 --- a/engine/libattributes.go +++ b/engine/libattributes.go @@ -24,11 +24,11 @@ import ( "github.com/cgrates/cgrates/utils" ) -type AttributeSubstitute struct { - FieldName string - Initial string - Alias string - Append bool +type Attribute struct { + FieldName string + Initial string + Substitute string + Append bool } type AttributeProfile struct { @@ -36,8 +36,8 @@ type AttributeProfile struct { ID string Context string // bind this AttributeProfile to specific context FilterIDs []string - ActivationInterval *utils.ActivationInterval // Activation interval - Substitutes map[string]map[string]*AttributeSubstitute // map[FieldName][InitialValue]*Attribute + ActivationInterval *utils.ActivationInterval // Activation interval + Attributes map[string]map[string]*Attribute // map[FieldName][InitialValue]*Attribute Weight float64 } @@ -59,7 +59,7 @@ type ExternalAttributeProfile struct { Context string // bind this AttributeProfile to specific context FilterIDs []string ActivationInterval *utils.ActivationInterval // Activation interval - Substitutes []*AttributeSubstitute + Attributes []*Attribute Weight float64 } @@ -72,12 +72,12 @@ func (eap *ExternalAttributeProfile) AsAttributeProfile() *AttributeProfile { ActivationInterval: eap.ActivationInterval, Weight: eap.Weight, } - alsMap := make(map[string]map[string]*AttributeSubstitute) - for _, als := range eap.Substitutes { - alsMap[als.FieldName] = make(map[string]*AttributeSubstitute) + alsMap := make(map[string]map[string]*Attribute) + for _, als := range eap.Attributes { + alsMap[als.FieldName] = make(map[string]*Attribute) alsMap[als.FieldName][als.Initial] = als } - alsPrf.Substitutes = alsMap + alsPrf.Attributes = alsMap return alsPrf } @@ -90,13 +90,13 @@ func NewExternalAttributeProfileFromAttributeProfile(alsPrf *AttributeProfile) * FilterIDs: alsPrf.FilterIDs, Weight: alsPrf.Weight, } - for key, val := range alsPrf.Substitutes { + for key, val := range alsPrf.Attributes { for key2, val2 := range val { - extals.Substitutes = append(extals.Substitutes, &AttributeSubstitute{ - FieldName: key, - Initial: key2, - Alias: val2.Alias, - Append: val2.Append, + extals.Attributes = append(extals.Attributes, &Attribute{ + FieldName: key, + Initial: key2, + Substitute: val2.Substitute, + Append: val2.Append, }) } } diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index aad3fb734..98682e3d7 100755 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -298,9 +298,9 @@ cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,, cgrates.org,SPP_1,,,,,supplier1,,,,ResGroup4,Stat3,10,, ` attributeProfiles = ` -#,Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Alias,Append,Weight -cgrates.org,ALS1,con1,FLTR_1,2014-07-29T15:00:00Z,Field1,Initial1,Alias1,true,20 -cgrates.org,ALS1,,,,Field2,Initial2,Alias2,false, +#,Tenant,ID,Context,FilterIDs,ActivationInterval,FieldName,Initial,Substitute,Append,Weight +cgrates.org,ALS1,con1,FLTR_1,2014-07-29T15:00:00Z,Field1,Initial1,Sub1,true,20 +cgrates.org,ALS1,,,,Field2,Initial2,Sub2,false, ` ) @@ -1550,23 +1550,23 @@ func TestLoadThresholdProfiles(t *testing.T) { } func TestLoadFilters(t *testing.T) { - eFilters := map[utils.TenantID]*utils.TPFilter{ - utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_1"}: &utils.TPFilter{ + eFilters := map[utils.TenantID]*utils.TPFilterProfile{ + utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_1"}: &utils.TPFilterProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "FLTR_1", - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Account", Type: "*string", Values: []string{"1001", "1002"}, }, - &utils.TPRequestFilter{ + &utils.TPFilter{ FieldName: "Destination", Type: "*string_prefix", Values: []string{"10", "20"}, }, - &utils.TPRequestFilter{ + &utils.TPFilter{ FieldName: "", Type: "*rsr_fields", Values: []string{"Subject(~^1.*1$)", "Destination(1002)"}, @@ -1576,12 +1576,12 @@ func TestLoadFilters(t *testing.T) { ActivationTime: "2014-07-29T15:00:00Z", }, }, - utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ACNT_dan"}: &utils.TPFilter{ + utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ACNT_dan"}: &utils.TPFilterProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "FLTR_ACNT_dan", - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Account", Type: "*string", Values: []string{"dan"}, @@ -1591,12 +1591,12 @@ func TestLoadFilters(t *testing.T) { ActivationTime: "2014-07-29T15:00:00Z", }, }, - utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_DST_DE"}: &utils.TPFilter{ + utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_DST_DE"}: &utils.TPFilterProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "FLTR_DST_DE", - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Destination", Type: "*destinations", Values: []string{"DST_DE"}, @@ -1606,12 +1606,12 @@ func TestLoadFilters(t *testing.T) { ActivationTime: "2014-07-29T15:00:00Z", }, }, - utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_DST_NL"}: &utils.TPFilter{ + utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_DST_NL"}: &utils.TPFilterProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "FLTR_DST_NL", - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Destination", Type: "*destinations", Values: []string{"DST_NL"}, @@ -1631,8 +1631,8 @@ func TestLoadFilters(t *testing.T) { } func TestLoadSupplierProfiles(t *testing.T) { - eSppProfiles := map[utils.TenantID]*utils.TPSupplier{ - utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPSupplier{ + eSppProfiles := map[utils.TenantID]*utils.TPSupplierProfile{ + utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPSupplierProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "SPP_1", @@ -1642,8 +1642,8 @@ func TestLoadSupplierProfiles(t *testing.T) { }, Sorting: "*lowest_cost", SortingParams: []string{}, - Suppliers: []*utils.TPRequestSupplier{ - &utils.TPRequestSupplier{ + Suppliers: []*utils.TPSupplier{ + &utils.TPSupplier{ ID: "supplier1", FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, AccountIDs: []string{"Account1", "Account1_1", "Account2"}, @@ -1666,8 +1666,8 @@ func TestLoadSupplierProfiles(t *testing.T) { } func TestLoadAttributeProfiles(t *testing.T) { - eAttrProfiles := map[utils.TenantID]*utils.TPAttribute{ - utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}: &utils.TPAttribute{ + eAttrProfiles := map[utils.TenantID]*utils.TPAttributeProfile{ + utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}: &utils.TPAttributeProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "ALS1", @@ -1676,18 +1676,18 @@ func TestLoadAttributeProfiles(t *testing.T) { ActivationTime: "2014-07-29T15:00:00Z", }, Context: "con1", - Substitutes: []*utils.TPAttributeSubstitute{ - &utils.TPAttributeSubstitute{ - FieldName: "Field1", - Initial: "Initial1", - Alias: "Alias1", - Append: true, + Attributes: []*utils.TPAttribute{ + &utils.TPAttribute{ + FieldName: "Field1", + Initial: "Initial1", + Substitute: "Alias1", + Append: true, }, - &utils.TPAttributeSubstitute{ - FieldName: "Field2", - Initial: "Initial2", - Alias: "Alias2", - Append: false, + &utils.TPAttribute{ + FieldName: "Field2", + Initial: "Initial2", + Substitute: "Alias2", + Append: false, }, }, Weight: 20, diff --git a/engine/model_helpers.go b/engine/model_helpers.go index 9818d21c8..1ef9958de 100755 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -2304,12 +2304,12 @@ func APItoThresholdProfile(tpTH *utils.TPThreshold, timezone string) (th *Thresh type TpFilterS []*TpFilter -func (tps TpFilterS) AsTPFilter() (result []*utils.TPFilter) { - mst := make(map[string]*utils.TPFilter) +func (tps TpFilterS) AsTPFilter() (result []*utils.TPFilterProfile) { + mst := make(map[string]*utils.TPFilterProfile) for _, tp := range tps { th, found := mst[tp.ID] if !found { - th = &utils.TPFilter{ + th = &utils.TPFilterProfile{ TPid: tp.Tpid, Tenant: tp.Tenant, ID: tp.ID, @@ -2326,14 +2326,14 @@ func (tps TpFilterS) AsTPFilter() (result []*utils.TPFilter) { } } if tp.FilterType != "" { - th.Filters = append(th.Filters, &utils.TPRequestFilter{ + th.Filters = append(th.Filters, &utils.TPFilter{ Type: tp.FilterType, FieldName: tp.FilterFieldName, Values: strings.Split(tp.FilterFieldValues, utils.INFIELD_SEP)}) } mst[tp.ID] = th } - result = make([]*utils.TPFilter, len(mst)) + result = make([]*utils.TPFilterProfile, len(mst)) i := 0 for _, th := range mst { result[i] = th @@ -2342,7 +2342,7 @@ func (tps TpFilterS) AsTPFilter() (result []*utils.TPFilter) { return } -func APItoModelTPFilter(th *utils.TPFilter) (mdls TpFilterS) { +func APItoModelTPFilter(th *utils.TPFilterProfile) (mdls TpFilterS) { if len(th.Filters) == 0 { return } @@ -2373,7 +2373,7 @@ func APItoModelTPFilter(th *utils.TPFilter) (mdls TpFilterS) { return } -func APItoFilter(tpTH *utils.TPFilter, timezone string) (th *Filter, err error) { +func APItoFilter(tpTH *utils.TPFilterProfile, timezone string) (th *Filter, err error) { th = &Filter{ Tenant: tpTH.Tenant, ID: tpTH.ID, @@ -2394,14 +2394,14 @@ func APItoFilter(tpTH *utils.TPFilter, timezone string) (th *Filter, err error) return th, nil } -func FilterToTPFilter(f *Filter) (tpFltr *utils.TPFilter) { - tpFltr = &utils.TPFilter{ +func FilterToTPFilter(f *Filter) (tpFltr *utils.TPFilterProfile) { + tpFltr = &utils.TPFilterProfile{ Tenant: f.Tenant, ID: f.ID, - Filters: make([]*utils.TPRequestFilter, len(f.RequestFilters)), + Filters: make([]*utils.TPFilter, len(f.RequestFilters)), } for i, reqFltr := range f.RequestFilters { - tpFltr.Filters[i] = &utils.TPRequestFilter{ + tpFltr.Filters[i] = &utils.TPFilter{ Type: reqFltr.Type, FieldName: reqFltr.FieldName, Values: make([]string, len(reqFltr.Values)), @@ -2421,14 +2421,14 @@ func FilterToTPFilter(f *Filter) (tpFltr *utils.TPFilter) { type TpSuppliers []*TpSupplier -func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplier) { +func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplierProfile) { filtermap := make(map[string]map[string]bool) - mst := make(map[string]*utils.TPSupplier) - suppliersMap := make(map[string]map[string]*utils.TPRequestSupplier) + mst := make(map[string]*utils.TPSupplierProfile) + suppliersMap := make(map[string]map[string]*utils.TPSupplier) for _, tp := range tps { th, found := mst[tp.ID] if !found { - th = &utils.TPSupplier{ + th = &utils.TPSupplierProfile{ TPid: tp.Tpid, Tenant: tp.Tenant, ID: tp.ID, @@ -2439,11 +2439,11 @@ func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplier) { } if tp.SupplierID != "" { if _, has := suppliersMap[tp.ID]; !has { - suppliersMap[tp.ID] = make(map[string]*utils.TPRequestSupplier) + suppliersMap[tp.ID] = make(map[string]*utils.TPSupplier) } sup, found := suppliersMap[tp.ID][tp.SupplierID] if !found { - sup = &utils.TPRequestSupplier{ + sup = &utils.TPSupplier{ ID: tp.SupplierID, Weight: tp.SupplierWeight, } @@ -2510,7 +2510,7 @@ func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplier) { } mst[tp.ID] = th } - result = make([]*utils.TPSupplier, len(mst)) + result = make([]*utils.TPSupplierProfile, len(mst)) i := 0 for _, th := range mst { result[i] = th @@ -2534,7 +2534,7 @@ func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplier) { return } -func APItoModelTPSuppliers(st *utils.TPSupplier) (mdls TpSuppliers) { +func APItoModelTPSuppliers(st *utils.TPSupplierProfile) (mdls TpSuppliers) { if len(st.Suppliers) == 0 { return } @@ -2600,7 +2600,7 @@ func APItoModelTPSuppliers(st *utils.TPSupplier) (mdls TpSuppliers) { return } -func APItoSupplierProfile(tpTH *utils.TPSupplier, timezone string) (th *SupplierProfile, err error) { +func APItoSupplierProfile(tpTH *utils.TPSupplierProfile, timezone string) (th *SupplierProfile, err error) { th = &SupplierProfile{ Tenant: tpTH.Tenant, ID: tpTH.ID, @@ -2636,12 +2636,12 @@ func APItoSupplierProfile(tpTH *utils.TPSupplier, timezone string) (th *Supplier type TPAttributes []*TPAttribute -func (tps TPAttributes) AsTPAttributes() (result []*utils.TPAttribute) { - mst := make(map[string]*utils.TPAttribute) +func (tps TPAttributes) AsTPAttributes() (result []*utils.TPAttributeProfile) { + mst := make(map[string]*utils.TPAttributeProfile) for _, tp := range tps { th, found := mst[tp.ID] if !found { - th = &utils.TPAttribute{ + th = &utils.TPAttributeProfile{ TPid: tp.Tpid, Tenant: tp.Tenant, ID: tp.ID, @@ -2670,16 +2670,16 @@ func (tps TPAttributes) AsTPAttributes() (result []*utils.TPAttribute) { th.Context = tp.Context } if tp.FieldName != "" { - th.Substitutes = append(th.Substitutes, &utils.TPAttributeSubstitute{ - FieldName: tp.FieldName, - Initial: tp.Initial, - Alias: tp.Alias, - Append: tp.Append, + th.Attributes = append(th.Attributes, &utils.TPAttribute{ + FieldName: tp.FieldName, + Initial: tp.Initial, + Substitute: tp.Substitute, + Append: tp.Append, }) } mst[tp.ID] = th } - result = make([]*utils.TPAttribute, len(mst)) + result = make([]*utils.TPAttributeProfile, len(mst)) i := 0 for _, th := range mst { result[i] = th @@ -2688,11 +2688,11 @@ func (tps TPAttributes) AsTPAttributes() (result []*utils.TPAttribute) { return } -func APItoModelTPAttribute(th *utils.TPAttribute) (mdls TPAttributes) { - if len(th.Substitutes) == 0 { +func APItoModelTPAttribute(th *utils.TPAttributeProfile) (mdls TPAttributes) { + if len(th.Attributes) == 0 { return } - for i, reqAttribute := range th.Substitutes { + for i, reqAttribute := range th.Attributes { mdl := &TPAttribute{ Tpid: th.TPid, Tenant: th.Tenant, @@ -2722,34 +2722,34 @@ func APItoModelTPAttribute(th *utils.TPAttribute) (mdls TPAttributes) { } mdl.FieldName = reqAttribute.FieldName mdl.Initial = reqAttribute.Initial - mdl.Alias = reqAttribute.Alias + mdl.Substitute = reqAttribute.Substitute mdl.Append = reqAttribute.Append mdls = append(mdls, mdl) } return } -func APItoAttributeProfile(tpTH *utils.TPAttribute, timezone string) (th *AttributeProfile, err error) { +func APItoAttributeProfile(tpTH *utils.TPAttributeProfile, timezone string) (th *AttributeProfile, err error) { th = &AttributeProfile{ - Tenant: tpTH.Tenant, - ID: tpTH.ID, - Weight: tpTH.Weight, - FilterIDs: []string{}, - Context: tpTH.Context, - Substitutes: make(map[string]map[string]*AttributeSubstitute, len(tpTH.Substitutes)), + Tenant: tpTH.Tenant, + ID: tpTH.ID, + Weight: tpTH.Weight, + FilterIDs: []string{}, + Context: tpTH.Context, + Attributes: make(map[string]map[string]*Attribute, len(tpTH.Attributes)), } for _, fli := range tpTH.FilterIDs { th.FilterIDs = append(th.FilterIDs, fli) } - for _, reqAttr := range tpTH.Substitutes { - if _, has := th.Substitutes[reqAttr.FieldName]; !has { - th.Substitutes[reqAttr.FieldName] = make(map[string]*AttributeSubstitute) + for _, reqAttr := range tpTH.Attributes { + if _, has := th.Attributes[reqAttr.FieldName]; !has { + th.Attributes[reqAttr.FieldName] = make(map[string]*Attribute) } - th.Substitutes[reqAttr.FieldName][reqAttr.Initial] = &AttributeSubstitute{ - FieldName: reqAttr.FieldName, - Initial: reqAttr.Initial, - Alias: reqAttr.Alias, - Append: reqAttr.Append, + th.Attributes[reqAttr.FieldName][reqAttr.Initial] = &Attribute{ + FieldName: reqAttr.FieldName, + Initial: reqAttr.Initial, + Substitute: reqAttr.Substitute, + Append: reqAttr.Append, } } if tpTH.ActivationInterval != nil { diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 2067b577e..8f0db3c40 100755 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -971,12 +971,12 @@ func TestTPFilterAsTPFilter(t *testing.T) { FilterFieldValues: "1001;1002", }, } - eTPs := []*utils.TPFilter{ - &utils.TPFilter{ + eTPs := []*utils.TPFilterProfile{ + &utils.TPFilterProfile{ TPid: tps[0].Tpid, ID: tps[0].ID, - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ Type: MetaStringPrefix, FieldName: "Account", Values: []string{"1001", "1002"}, @@ -992,12 +992,12 @@ func TestTPFilterAsTPFilter(t *testing.T) { } func TestAPItoTPFilter(t *testing.T) { - tps := &utils.TPFilter{ + tps := &utils.TPFilterProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "Filter1", - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Account", Type: "*string", Values: []string{"1001", "1002"}, @@ -1039,15 +1039,15 @@ func TestFilterToTPFilter(t *testing.T) { }, }, } - tpfilter := &utils.TPFilter{ + tpfilter := &utils.TPFilterProfile{ ID: "Fltr1", Tenant: "cgrates.org", ActivationInterval: &utils.TPActivationInterval{ ActivationTime: "2014-01-14T00:00:00Z", ExpiryTime: "2014-01-14T00:00:00Z", }, - Filters: []*utils.TPRequestFilter{ - &utils.TPRequestFilter{ + Filters: []*utils.TPFilter{ + &utils.TPFilter{ FieldName: "Account", Type: "*string", Values: []string{"1001", "1002"}, @@ -1061,7 +1061,7 @@ func TestFilterToTPFilter(t *testing.T) { } func TestAPItoAttributeProfile(t *testing.T) { - tpAlsPrf := &utils.TPAttribute{ + tpAlsPrf := &utils.TPAttributeProfile{ TPid: "TP1", Tenant: "cgrates.org", ID: "ALS1", @@ -1071,23 +1071,23 @@ func TestAPItoAttributeProfile(t *testing.T) { ActivationTime: "2014-07-14T14:35:00Z", ExpiryTime: "", }, - Substitutes: []*utils.TPAttributeSubstitute{ - &utils.TPAttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + Attributes: []*utils.TPAttribute{ + &utils.TPAttribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, }, }, Weight: 20, } - attrMap := make(map[string]map[string]*AttributeSubstitute) - attrMap["FL1"] = make(map[string]*AttributeSubstitute) - attrMap["FL1"]["In1"] = &AttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + attrMap := make(map[string]map[string]*Attribute) + attrMap["FL1"] = make(map[string]*Attribute) + attrMap["FL1"]["In1"] = &Attribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, } expected := &AttributeProfile{ Tenant: "cgrates.org", @@ -1097,8 +1097,8 @@ func TestAPItoAttributeProfile(t *testing.T) { ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), }, - Substitutes: attrMap, - Weight: 20, + Attributes: attrMap, + Weight: 20, } if rcv, err := APItoAttributeProfile(tpAlsPrf, "UTC"); err != nil { t.Error(err) @@ -1108,7 +1108,7 @@ func TestAPItoAttributeProfile(t *testing.T) { } func TestAPItoModelTPAttribute(t *testing.T) { - tpAlsPrf := &utils.TPAttribute{ + tpAlsPrf := &utils.TPAttributeProfile{ TPid: "TP1", Tenant: "cgrates.org", ID: "ALS1", @@ -1118,12 +1118,12 @@ func TestAPItoModelTPAttribute(t *testing.T) { ActivationTime: "2014-07-14T14:35:00Z", ExpiryTime: "", }, - Substitutes: []*utils.TPAttributeSubstitute{ - &utils.TPAttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + Attributes: []*utils.TPAttribute{ + &utils.TPAttribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, }, }, Weight: 20, @@ -1137,7 +1137,7 @@ func TestAPItoModelTPAttribute(t *testing.T) { FilterIDs: "FLTR_ACNT_dan;FLTR_DST_DE", FieldName: "FL1", Initial: "In1", - Alias: "Al1", + Substitute: "Al1", Append: true, ActivationInterval: "2014-07-14T14:35:00Z", Weight: 20, @@ -1159,13 +1159,13 @@ func TestModelAsTPAttribute(t *testing.T) { FilterIDs: "FLTR_ACNT_dan;FLTR_DST_DE", FieldName: "FL1", Initial: "In1", - Alias: "Al1", + Substitute: "Al1", Append: true, ActivationInterval: "2014-07-14T14:35:00Z", Weight: 20, }, } - expected := &utils.TPAttribute{ + expected := &utils.TPAttributeProfile{ TPid: "TP1", Tenant: "cgrates.org", ID: "ALS1", @@ -1175,12 +1175,12 @@ func TestModelAsTPAttribute(t *testing.T) { ActivationTime: "2014-07-14T14:35:00Z", ExpiryTime: "", }, - Substitutes: []*utils.TPAttributeSubstitute{ - &utils.TPAttributeSubstitute{ - FieldName: "FL1", - Initial: "In1", - Alias: "Al1", - Append: true, + Attributes: []*utils.TPAttribute{ + &utils.TPAttribute{ + FieldName: "FL1", + Initial: "In1", + Substitute: "Al1", + Append: true, }, }, Weight: 20, diff --git a/engine/models.go b/engine/models.go index dc4c1992e..5845a7004 100755 --- a/engine/models.go +++ b/engine/models.go @@ -551,7 +551,7 @@ type TPAttribute struct { ActivationInterval string `index:"4" re:""` FieldName string `index:"5" re:""` Initial string `index:"6" re:""` - Alias string `index:"7" re:""` + Substitute string `index:"7" re:""` Append bool `index:"8" re:""` Weight float64 `index:"9" re:"\d+\.?\d*"` CreatedAt time.Time diff --git a/engine/storage_csv.go b/engine/storage_csv.go index de4843739..ae32cc50c 100755 --- a/engine/storage_csv.go +++ b/engine/storage_csv.go @@ -686,7 +686,7 @@ func (csvs *CSVStorage) GetTPThresholds(tpid, id string) ([]*utils.TPThreshold, return tpThreshold.AsTPThreshold(), nil } -func (csvs *CSVStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) { +func (csvs *CSVStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilterProfile, error) { csvReader, fp, err := csvs.readerFunc(csvs.filterFn, csvs.sep, getColumnCount(TpFilter{})) if err != nil { //log.Print("Could not load filter file: ", err) @@ -714,7 +714,7 @@ func (csvs *CSVStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) return tpFilter.AsTPFilter(), nil } -func (csvs *CSVStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, error) { +func (csvs *CSVStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplierProfile, error) { csvReader, fp, err := csvs.readerFunc(csvs.suppProfilesFn, csvs.sep, getColumnCount(TpSupplier{})) if err != nil { //log.Print("Could not load lcrProfile file: ", err) @@ -742,10 +742,10 @@ func (csvs *CSVStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, er return tpSPPs.AsTPSuppliers(), nil } -func (csvs *CSVStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) { +func (csvs *CSVStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttributeProfile, error) { csvReader, fp, err := csvs.readerFunc(csvs.attributeProfilesFn, csvs.sep, getColumnCount(TPAttribute{})) if err != nil { - //log.Print("Could not load AliasProfile file: ", err) + //log.Print("Could not load AttributeProfile file: ", err) // allow writing of the other values return nil, nil } diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 74e076559..df263e05a 100755 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -188,9 +188,9 @@ type LoadReader interface { GetTPResources(string, string) ([]*utils.TPResource, error) GetTPStats(string, string) ([]*utils.TPStats, error) GetTPThresholds(string, string) ([]*utils.TPThreshold, error) - GetTPFilters(string, string) ([]*utils.TPFilter, error) - GetTPSuppliers(string, string) ([]*utils.TPSupplier, error) - GetTPAttributes(string, string) ([]*utils.TPAttribute, error) + GetTPFilters(string, string) ([]*utils.TPFilterProfile, error) + GetTPSuppliers(string, string) ([]*utils.TPSupplierProfile, error) + GetTPAttributes(string, string) ([]*utils.TPAttributeProfile, error) } type LoadWriter interface { @@ -214,9 +214,9 @@ type LoadWriter interface { SetTPResources([]*utils.TPResource) error SetTPStats([]*utils.TPStats) error SetTPThresholds([]*utils.TPThreshold) error - SetTPFilters([]*utils.TPFilter) error - SetTPSuppliers([]*utils.TPSupplier) error - SetTPAttributes([]*utils.TPAttribute) error + SetTPFilters([]*utils.TPFilterProfile) error + SetTPSuppliers([]*utils.TPSupplierProfile) error + SetTPAttributes([]*utils.TPAttributeProfile) error } // NewMarshaler returns the marshaler type selected by mrshlerStr diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go index 288945e1e..950d6abbd 100755 --- a/engine/storage_mongo_stordb.go +++ b/engine/storage_mongo_stordb.go @@ -1196,14 +1196,14 @@ func (ms *MongoStorage) SetTPThresholds(tpTHs []*utils.TPThreshold) (err error) return } -func (ms *MongoStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) { +func (ms *MongoStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilterProfile, error) { filter := bson.M{ "tpid": tpid, } if id != "" { filter["id"] = id } - var results []*utils.TPFilter + var results []*utils.TPFilterProfile session, col := ms.conn(utils.TBLTPFilters) defer session.Close() err := col.Find(filter).All(&results) @@ -1213,7 +1213,7 @@ func (ms *MongoStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) return results, err } -func (ms *MongoStorage) SetTPFilters(tpTHs []*utils.TPFilter) (err error) { +func (ms *MongoStorage) SetTPFilters(tpTHs []*utils.TPFilterProfile) (err error) { if len(tpTHs) == 0 { return } @@ -1227,14 +1227,14 @@ func (ms *MongoStorage) SetTPFilters(tpTHs []*utils.TPFilter) (err error) { return } -func (ms *MongoStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, error) { +func (ms *MongoStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplierProfile, error) { filter := bson.M{ "tpid": tpid, } if id != "" { filter["id"] = id } - var results []*utils.TPSupplier + var results []*utils.TPSupplierProfile session, col := ms.conn(utils.TBLTPSuppliers) defer session.Close() err := col.Find(filter).All(&results) @@ -1244,7 +1244,7 @@ func (ms *MongoStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, er return results, err } -func (ms *MongoStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) (err error) { +func (ms *MongoStorage) SetTPSuppliers(tpSPs []*utils.TPSupplierProfile) (err error) { if len(tpSPs) == 0 { return } @@ -1258,14 +1258,14 @@ func (ms *MongoStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) (err error) { return } -func (ms *MongoStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) { +func (ms *MongoStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttributeProfile, error) { filter := bson.M{ "tpid": tpid, } if id != "" { filter["id"] = id } - var results []*utils.TPAttribute + var results []*utils.TPAttributeProfile session, col := ms.conn(utils.TBLTPAttributes) defer session.Close() err := col.Find(filter).All(&results) @@ -1275,7 +1275,7 @@ func (ms *MongoStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, return results, err } -func (ms *MongoStorage) SetTPAttributes(tpSPs []*utils.TPAttribute) (err error) { +func (ms *MongoStorage) SetTPAttributes(tpSPs []*utils.TPAttributeProfile) (err error) { if len(tpSPs) == 0 { return } diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 4eee84321..6ddee3b4b 100755 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -672,7 +672,7 @@ func (self *SQLStorage) SetTPThresholds(ths []*utils.TPThreshold) error { return nil } -func (self *SQLStorage) SetTPFilters(ths []*utils.TPFilter) error { +func (self *SQLStorage) SetTPFilters(ths []*utils.TPFilterProfile) error { if len(ths) == 0 { return nil } @@ -694,7 +694,7 @@ func (self *SQLStorage) SetTPFilters(ths []*utils.TPFilter) error { return nil } -func (self *SQLStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) error { +func (self *SQLStorage) SetTPSuppliers(tpSPs []*utils.TPSupplierProfile) error { if len(tpSPs) == 0 { return nil } @@ -716,7 +716,7 @@ func (self *SQLStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) error { return nil } -func (self *SQLStorage) SetTPAttributes(tpAttrs []*utils.TPAttribute) error { +func (self *SQLStorage) SetTPAttributes(tpAttrs []*utils.TPAttributeProfile) error { if len(tpAttrs) == 0 { return nil } @@ -1565,7 +1565,7 @@ func (self *SQLStorage) GetTPThresholds(tpid, id string) ([]*utils.TPThreshold, return aths, nil } -func (self *SQLStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) { +func (self *SQLStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilterProfile, error) { var ths TpFilterS q := self.db.Where("tpid = ?", tpid) if len(id) != 0 { @@ -1581,7 +1581,7 @@ func (self *SQLStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error) return aths, nil } -func (self *SQLStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, error) { +func (self *SQLStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplierProfile, error) { var sps TpSuppliers q := self.db.Where("tpid = ?", tpid) if len(id) != 0 { @@ -1597,7 +1597,7 @@ func (self *SQLStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, er return arls, nil } -func (self *SQLStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) { +func (self *SQLStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttributeProfile, error) { var sps TPAttributes q := self.db.Where("tpid = ?", tpid) if len(id) != 0 { diff --git a/engine/tp_reader.go b/engine/tp_reader.go index 2a3be4226..6886e63dd 100755 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -56,9 +56,9 @@ type TpReader struct { resProfiles map[utils.TenantID]*utils.TPResource sqProfiles map[utils.TenantID]*utils.TPStats thProfiles map[utils.TenantID]*utils.TPThreshold - filters map[utils.TenantID]*utils.TPFilter - sppProfiles map[utils.TenantID]*utils.TPSupplier - attributeProfiles map[utils.TenantID]*utils.TPAttribute + filters map[utils.TenantID]*utils.TPFilterProfile + sppProfiles map[utils.TenantID]*utils.TPSupplierProfile + attributeProfiles map[utils.TenantID]*utils.TPAttributeProfile resources []*utils.TenantID // IDs of resources which need creation based on resourceProfiles statQueues []*utils.TenantID // IDs of statQueues which need creation based on statQueueProfiles thresholds []*utils.TenantID // IDs of thresholds which need creation based on thresholdProfiles @@ -142,9 +142,9 @@ func (tpr *TpReader) Init() { tpr.resProfiles = make(map[utils.TenantID]*utils.TPResource) tpr.sqProfiles = make(map[utils.TenantID]*utils.TPStats) tpr.thProfiles = make(map[utils.TenantID]*utils.TPThreshold) - tpr.sppProfiles = make(map[utils.TenantID]*utils.TPSupplier) - tpr.attributeProfiles = make(map[utils.TenantID]*utils.TPAttribute) - tpr.filters = make(map[utils.TenantID]*utils.TPFilter) + tpr.sppProfiles = make(map[utils.TenantID]*utils.TPSupplierProfile) + tpr.attributeProfiles = make(map[utils.TenantID]*utils.TPAttributeProfile) + tpr.filters = make(map[utils.TenantID]*utils.TPFilterProfile) tpr.revDests = make(map[string][]string) tpr.revAliases = make(map[string][]string) tpr.acntActionPlans = make(map[string][]string) @@ -1755,7 +1755,7 @@ func (tpr *TpReader) LoadFiltersFiltered(tag string) error { if err != nil { return err } - mapTHs := make(map[utils.TenantID]*utils.TPFilter) + mapTHs := make(map[utils.TenantID]*utils.TPFilterProfile) for _, th := range tps { mapTHs[utils.TenantID{Tenant: th.Tenant, ID: th.ID}] = th } @@ -1772,7 +1772,7 @@ func (tpr *TpReader) LoadSupplierProfilesFiltered(tag string) (err error) { if err != nil { return err } - mapRsPfls := make(map[utils.TenantID]*utils.TPSupplier) + mapRsPfls := make(map[utils.TenantID]*utils.TPSupplierProfile) for _, rl := range rls { mapRsPfls[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl } @@ -1818,7 +1818,7 @@ func (tpr *TpReader) LoadAttributeProfilesFiltered(tag string) (err error) { if err != nil { return err } - mapRsPfls := make(map[utils.TenantID]*utils.TPAttribute) + mapRsPfls := make(map[utils.TenantID]*utils.TPAttributeProfile) for _, rl := range rls { mapRsPfls[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 4abe92d88..2592140b5 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -1345,21 +1345,21 @@ type TPThreshold struct { Async bool } -type TPFilter struct { +type TPFilterProfile struct { TPid string Tenant string ID string - Filters []*TPRequestFilter + Filters []*TPFilter ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires } -type TPRequestFilter struct { +type TPFilter struct { Type string // Filter type (*string, *timing, *rsr_filters, *cdr_stats) FieldName string // Name of the field providing us the Values to check (used in case of some ) Values []string // Filter definition } -type TPRequestSupplier struct { +type TPSupplier struct { ID string // SupplierID FilterIDs []string AccountIDs []string @@ -1369,7 +1369,7 @@ type TPRequestSupplier struct { Weight float64 } -type TPSupplier struct { +type TPSupplierProfile struct { TPid string Tenant string ID string @@ -1377,25 +1377,25 @@ type TPSupplier struct { ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires Sorting string SortingParams []string - Suppliers []*TPRequestSupplier + Suppliers []*TPSupplier Blocker bool Weight float64 } -type TPAttributeSubstitute struct { - FieldName string - Initial string - Alias string - Append bool +type TPAttribute struct { + FieldName string + Initial string + Substitute string + Append bool } -type TPAttribute struct { +type TPAttributeProfile struct { TPid string Tenant string ID string FilterIDs []string ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires Context string // bind this TPAttribute to specific context - Substitutes []*TPAttributeSubstitute + Attributes []*TPAttribute Weight float64 }