mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Removed all unecessary if from all AsNavigableMap methods
This commit is contained in:
committed by
Dan Christian Bogos
parent
d0a314743c
commit
129b3905fd
@@ -1810,40 +1810,38 @@ func (v1AuthReply *V1AuthorizeReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||
func (v1AuthReply *V1AuthorizeReply) AsNavigableMap() utils.NavigableMap2 {
|
||||
cgrReply := make(utils.NavigableMap2)
|
||||
if v1AuthReply != nil {
|
||||
if v1AuthReply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1AuthReply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1AuthReply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1AuthReply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
if v1AuthReply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1AuthReply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1AuthReply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1AuthReply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1AuthReply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1AuthReply.ResourceAllocation)
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1AuthReply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1AuthReply.ResourceAllocation)
|
||||
}
|
||||
if v1AuthReply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1AuthReply.MaxUsage)
|
||||
}
|
||||
if v1AuthReply.Suppliers != nil {
|
||||
cgrReply[utils.CapSuppliers] = v1AuthReply.Suppliers.AsNavigableMap()
|
||||
}
|
||||
if v1AuthReply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1AuthReply.ThresholdIDs))
|
||||
for i, v := range *v1AuthReply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
if v1AuthReply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1AuthReply.MaxUsage)
|
||||
}
|
||||
if v1AuthReply.Suppliers != nil {
|
||||
cgrReply[utils.CapSuppliers] = v1AuthReply.Suppliers.AsNavigableMap()
|
||||
}
|
||||
if v1AuthReply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1AuthReply.ThresholdIDs))
|
||||
for i, v := range *v1AuthReply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
}
|
||||
if v1AuthReply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1AuthReply.StatQueueIDs))
|
||||
for i, v := range *v1AuthReply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
}
|
||||
if v1AuthReply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1AuthReply.StatQueueIDs))
|
||||
for i, v := range *v1AuthReply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
}
|
||||
return cgrReply
|
||||
}
|
||||
@@ -2093,38 +2091,36 @@ func (v1Rply *V1InitSessionReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||
func (v1Rply *V1InitSessionReply) AsNavigableMap() utils.NavigableMap2 {
|
||||
cgrReply := make(utils.NavigableMap2)
|
||||
if v1Rply != nil {
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation)
|
||||
}
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation)
|
||||
}
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
|
||||
if v1Rply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1Rply.ThresholdIDs))
|
||||
for i, v := range *v1Rply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
if v1Rply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1Rply.ThresholdIDs))
|
||||
for i, v := range *v1Rply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
if v1Rply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1Rply.StatQueueIDs))
|
||||
for i, v := range *v1Rply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
}
|
||||
if v1Rply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1Rply.StatQueueIDs))
|
||||
for i, v := range *v1Rply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
}
|
||||
return cgrReply
|
||||
}
|
||||
@@ -2339,20 +2335,18 @@ func (v1Rply *V1UpdateSessionReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||
func (v1Rply *V1UpdateSessionReply) AsNavigableMap() utils.NavigableMap2 {
|
||||
cgrReply := make(utils.NavigableMap2)
|
||||
if v1Rply != nil {
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
return cgrReply
|
||||
}
|
||||
@@ -2821,40 +2815,38 @@ func (v1Rply *V1ProcessMessageReply) SetMaxUsageNeeded(getMaxUsage bool) {
|
||||
// AsNavigableMap is part of engine.NavigableMapper interface
|
||||
func (v1Rply *V1ProcessMessageReply) AsNavigableMap() utils.NavigableMap2 {
|
||||
cgrReply := make(utils.NavigableMap2)
|
||||
if v1Rply != nil {
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
if v1Rply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation)
|
||||
}
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
if v1Rply.getMaxUsage {
|
||||
cgrReply[utils.CapMaxUsage] = utils.NewNMData(v1Rply.MaxUsage)
|
||||
}
|
||||
if v1Rply.ResourceAllocation != nil {
|
||||
cgrReply[utils.CapResourceAllocation] = utils.NewNMData(*v1Rply.ResourceAllocation)
|
||||
}
|
||||
if v1Rply.Attributes != nil {
|
||||
attrs := make(utils.NavigableMap2)
|
||||
for _, fldName := range v1Rply.Attributes.AlteredFields {
|
||||
fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep)
|
||||
if v1Rply.Attributes.CGREvent.HasField(fldName) {
|
||||
attrs[fldName] = utils.NewNMData(v1Rply.Attributes.CGREvent.Event[fldName])
|
||||
}
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.Suppliers != nil {
|
||||
cgrReply[utils.CapSuppliers] = v1Rply.Suppliers.AsNavigableMap()
|
||||
cgrReply[utils.CapAttributes] = attrs
|
||||
}
|
||||
if v1Rply.Suppliers != nil {
|
||||
cgrReply[utils.CapSuppliers] = v1Rply.Suppliers.AsNavigableMap()
|
||||
}
|
||||
if v1Rply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1Rply.ThresholdIDs))
|
||||
for i, v := range *v1Rply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
if v1Rply.ThresholdIDs != nil {
|
||||
thIDs := make(utils.NMSlice, len(*v1Rply.ThresholdIDs))
|
||||
for i, v := range *v1Rply.ThresholdIDs {
|
||||
thIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
}
|
||||
if v1Rply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1Rply.StatQueueIDs))
|
||||
for i, v := range *v1Rply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
cgrReply[utils.CapThresholds] = &thIDs
|
||||
}
|
||||
if v1Rply.StatQueueIDs != nil {
|
||||
stIDs := make(utils.NMSlice, len(*v1Rply.StatQueueIDs))
|
||||
for i, v := range *v1Rply.StatQueueIDs {
|
||||
stIDs[i] = utils.NewNMData(v)
|
||||
}
|
||||
cgrReply[utils.CapStatQueues] = &stIDs
|
||||
}
|
||||
return cgrReply
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user