hierarchy

package
v1.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("failed to build hierarchy as it already exists")

Functions

func CreateCSV

func CreateCSV(nodes []*Node, writer io.Writer) error

CreateCSV creates a CSV representation of the given nodes and writes it to the given file.

func CreateCSVFile

func CreateCSVFile(nodes []*Node, filename string) error

CreateCSVFile generates hierarchy csv content and writes it to the given file.

func PopulateChildNodes

func PopulateChildNodes(ctx context.Context, nodes *map[string]*Node)

PopulateChildNodes takes a flat map of nodes and populates the children slice for each node.

Types

type DB added in v1.11.1

type DB = driver.Hierarchy // type is declared locally to enable the above moq generation

type Node

type Node struct {
	Level      int
	Code       string
	CodeList   string
	ParentCode string

	Label           string
	LabelCode       string
	ParentLabelCode string

	Children []*Node
}

Node represents a single node in a hierarchy, linking to child nodes.

func IdentifyRootNodes

func IdentifyRootNodes(nodes *map[string]*Node) []*Node

IdentifyRootNodes returns a slice of nodes from the given map that have no parent.

type Store

type Store struct {
	DB
}

Store represents storage for hierarchy data.

func (*Store) BuildHierarchy

func (store *Store) BuildHierarchy(instanceID, codeListID, dimensionName string) error

BuildHierarchy clones the necessary generic hierarchy subgraph, according to the existing codes in the nodes for instanceID and dimensionName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL