Documentation ¶
Index ¶
- Constants
- type GetParamFunc
- type Model
- func (m *Model) CreateAttributeRec(rec *record.AppAttributeRecord) (err error)
- func (m *Model) DeleteAttributeRec(appAttributeID string) (err error)
- func (m *Model) GetAttributeRec(ID string) (rec *record.AppAttributeRecord, err error)
- func (m *Model) GetAttributeRecs(params map[string]interface{}) (recs []*record.AppAttributeRecord, err error)
- func (m *Model) GetAttributeValues(rec *record.AppAttributeRecord, params map[string]int) (calculatedValue, minValue, maxValue int, err error)
- func (m *Model) GetEntityAttributeValue(rec *record.AppEntityAttributeRecord, params map[string]int) (calculatedValue, minValue, maxValue int, err error)
- func (m *Model) GetEntityAttributeValues(recs []*record.AppEntityAttributeRecord) (map[string]int, error)
- func (m *Model) GetFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
- func (m *Model) GetMaxValueFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
- func (m *Model) GetMinValueFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
- func (m *Model) Init() error
- func (m *Model) OrderAttributeRecs(attrs []*record.AppAttributeRecord) error
- func (m *Model) OrderEntityAttributeRecs(attrs []*record.AppEntityAttributeRecord) error
- func (m *Model) UpdateAttributeRec(rec *record.AppAttributeRecord) (err error)
- func (m *Model) ValidateAttributeRecs(attrs []*record.AppAttributeRecord) error
- func (m *Model) ValidateAttributes(appID string) error
- func (m *Model) ValidateEntityAttributeRecs(attrs []*record.AppEntityAttributeRecord) error
- type SortableAttribute
- type Sorter
Constants ¶
const ( // ModelName - ModelName string = "attribute" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetParamFunc ¶
GetParamFunc - Function that returns formula parameters from an attribute record
type Model ¶
Model -
func (*Model) CreateAttributeRec ¶
func (m *Model) CreateAttributeRec(rec *record.AppAttributeRecord) (err error)
CreateAttributeRec -
func (*Model) DeleteAttributeRec ¶
DeleteAttributeRec -
func (*Model) GetAttributeRec ¶
func (m *Model) GetAttributeRec(ID string) (rec *record.AppAttributeRecord, err error)
GetAttributeRec -
func (*Model) GetAttributeRecs ¶
func (m *Model) GetAttributeRecs(params map[string]interface{}) (recs []*record.AppAttributeRecord, err error)
GetAttributeRecs -
func (*Model) GetAttributeValues ¶
func (m *Model) GetAttributeValues(rec *record.AppAttributeRecord, params map[string]int) ( calculatedValue, minValue, maxValue int, err error)
GetAttributeValues - returns the calculated, min and max values of an attribute based on its formula, params is expected to contain calculated values for existing attributes that the formula depends on. Be sure to OrderEntityAttributes before attempting to cycle calculating their values.
func (*Model) GetEntityAttributeValue ¶
func (m *Model) GetEntityAttributeValue(rec *record.AppEntityAttributeRecord, params map[string]int) ( calculatedValue, minValue, maxValue int, err error)
GetEntityAttributeValue - See GetAttributeValue
func (*Model) GetEntityAttributeValues ¶
func (m *Model) GetEntityAttributeValues(recs []*record.AppEntityAttributeRecord) (map[string]int, error)
GetEntityAttributeValues - Sorts, calculates and returns resulting values
func (*Model) GetFormulaParams ¶
func (m *Model) GetFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
GetFormulaParams - returns array of parameter names from the formula that are required to calculate an attribute value.
func (*Model) GetMaxValueFormulaParams ¶
func (m *Model) GetMaxValueFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
GetMaxValueFormulaParams -
func (*Model) GetMinValueFormulaParams ¶
func (m *Model) GetMinValueFormulaParams(rec *record.AppAttributeRecord) (params []string, err error)
GetMinValueFormulaParams -
func (*Model) OrderAttributeRecs ¶
func (m *Model) OrderAttributeRecs(attrs []*record.AppAttributeRecord) error
OrderAttributeRecs - orders attributes based on formula parameter dependencies, to be used for ordering attributes prior to calculating attribute values.
func (*Model) OrderEntityAttributeRecs ¶
func (m *Model) OrderEntityAttributeRecs(attrs []*record.AppEntityAttributeRecord) error
OrderEntityAttributeRecs - see OrderAttributes
func (*Model) UpdateAttributeRec ¶
func (m *Model) UpdateAttributeRec(rec *record.AppAttributeRecord) (err error)
UpdateAttributeRec -
func (*Model) ValidateAttributeRecs ¶
func (m *Model) ValidateAttributeRecs(attrs []*record.AppAttributeRecord) error
ValidateAttributeRecs - checks attributes to ensure there are no cyclic dependencies in formula params, that is, attribute X cannot depend on attribute Y that also depends on attribute X. Also checks that all attribute formula are correct. This function assumes attribute records are ordered before being passed in.
func (*Model) ValidateAttributes ¶
ValidateAttributes -
func (*Model) ValidateEntityAttributeRecs ¶
func (m *Model) ValidateEntityAttributeRecs(attrs []*record.AppEntityAttributeRecord) error
ValidateEntityAttributeRecs - checks attributes to ensure there are no cyclic dependencies in formula params, that is, attribute X cannot depend on attribute Y that also depends on attribute X. Also checks that all attribute formula are correct. This function assumes attribute records are ordered before being passed in.
type SortableAttribute ¶
type SortableAttribute struct { AttributeRec *record.AppAttributeRecord EntityAttributeRec *record.AppEntityAttributeRecord }
SortableAttribute -
type Sorter ¶
type Sorter struct { Logger zerolog.Logger SwapA int SwapB int GetParamFunc GetParamFunc Attributes []*SortableAttribute }
Sorter -