mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
119 lines
3.5 KiB
Go
Executable File
119 lines
3.5 KiB
Go
Executable File
/*
|
|
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
|
Copyright (C) ITsysCOM GmbH
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
package config
|
|
|
|
func NewFCTemplateFromFCTemplateJsonCfg(jsnCfg *FcTemplateJsonCfg) *FCTemplate {
|
|
fcTmp := new(FCTemplate)
|
|
if jsnCfg.Tag != nil {
|
|
fcTmp.Tag = *jsnCfg.Tag
|
|
}
|
|
if jsnCfg.Type != nil {
|
|
fcTmp.Type = *jsnCfg.Type
|
|
}
|
|
if jsnCfg.Field_id != nil {
|
|
fcTmp.FieldId = *jsnCfg.Field_id
|
|
}
|
|
if jsnCfg.Filters != nil {
|
|
fcTmp.Filters = make([]string, len(*jsnCfg.Filters))
|
|
for i, fltr := range *jsnCfg.Filters {
|
|
fcTmp.Filters[i] = fltr
|
|
}
|
|
}
|
|
if jsnCfg.Value != nil {
|
|
fcTmp.Value = NewRSRParsersMustCompile(*jsnCfg.Value, true)
|
|
}
|
|
if jsnCfg.Width != nil {
|
|
fcTmp.Width = *jsnCfg.Width
|
|
}
|
|
if jsnCfg.Strip != nil {
|
|
fcTmp.Strip = *jsnCfg.Strip
|
|
}
|
|
if jsnCfg.Padding != nil {
|
|
fcTmp.Padding = *jsnCfg.Padding
|
|
}
|
|
if jsnCfg.Mandatory != nil {
|
|
fcTmp.Mandatory = *jsnCfg.Mandatory
|
|
}
|
|
if jsnCfg.Attribute_id != nil {
|
|
fcTmp.AttributeID = *jsnCfg.Attribute_id
|
|
}
|
|
if jsnCfg.New_branch != nil {
|
|
fcTmp.NewBranch = *jsnCfg.New_branch
|
|
}
|
|
if jsnCfg.Timezone != nil {
|
|
fcTmp.Timezone = *jsnCfg.Timezone
|
|
}
|
|
if jsnCfg.Blocker != nil {
|
|
fcTmp.Blocker = *jsnCfg.Blocker
|
|
}
|
|
if jsnCfg.Break_on_success != nil {
|
|
fcTmp.BreakOnSuccess = *jsnCfg.Break_on_success
|
|
}
|
|
if jsnCfg.Handler_id != nil {
|
|
fcTmp.HandlerId = *jsnCfg.Handler_id
|
|
}
|
|
if jsnCfg.Layout != nil {
|
|
fcTmp.Layout = *jsnCfg.Layout
|
|
}
|
|
if jsnCfg.Cost_shift_digits != nil {
|
|
fcTmp.CostShiftDigits = *jsnCfg.Cost_shift_digits
|
|
}
|
|
if jsnCfg.Rounding_decimals != nil {
|
|
fcTmp.RoundingDecimals = *jsnCfg.Rounding_decimals
|
|
}
|
|
if jsnCfg.Mask_destinationd_id != nil {
|
|
fcTmp.MaskDestID = *jsnCfg.Mask_destinationd_id
|
|
}
|
|
if jsnCfg.Mask_length != nil {
|
|
fcTmp.MaskLen = *jsnCfg.Mask_length
|
|
}
|
|
return fcTmp
|
|
}
|
|
|
|
type FCTemplate struct {
|
|
Tag string
|
|
Type string // Type of field
|
|
FieldId string // Field identifier
|
|
Filters []string // list of filter profiles
|
|
Value RSRParsers
|
|
Width int
|
|
Strip string
|
|
Padding string
|
|
Mandatory bool
|
|
AttributeID string // Used by NavigableMap when creating CGREvent/XMLElements
|
|
NewBranch bool // Used by NavigableMap when creating XMLElements
|
|
Timezone string
|
|
Blocker bool
|
|
BreakOnSuccess bool
|
|
HandlerId string // used by XML in CDRC
|
|
Layout string // time format
|
|
CostShiftDigits int // Used for CDR
|
|
RoundingDecimals int
|
|
MaskDestID string
|
|
MaskLen int
|
|
}
|
|
|
|
func FCTemplatesFromFCTemapltesJsonCfg(jsnCfgFlds []*FcTemplateJsonCfg) []*FCTemplate {
|
|
retFields := make([]*FCTemplate, len(jsnCfgFlds))
|
|
for i, jsnFld := range jsnCfgFlds {
|
|
retFields[i] = NewFCTemplateFromFCTemplateJsonCfg(jsnFld)
|
|
}
|
|
return retFields
|
|
}
|