I have Nodes model: package model import ( validation…
- User
I have Nodes model: package model
import ( validation “github.com/go-ozzo/ozzo-validation/v4” )
// Node is custom type that represents *model.ENodeB and *model.EUtranCellData // of cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is custom type that represents map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err } return nil }
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { for name, node := range *nodes { if err := node.ValidateNode(); err != nil { return validation.Errors{ name: err, } } } return nil }
Now I correct following code, so funcs GetName, GetSubType, would run for each eNode in Node
package model
// Eranintegrjob is custom type that holds all job required // for Eran integration type ElasticRan struct { Job ENodeB
json:"parenteNodeB"SubNetworkjson:"subnetwork"EranConnectionjson:"eranConnection"Nodesjson:"nodes"BaselineId int }// GetName returns job eNodeB name func (job *ElasticRan) GetName() string { return job.Nodes.ENodeB.Site.Cellular.Name }
- Assistant
package model
// Eranintegrjob is custom type that holds all job required // for Eran integration type ElasticRan struct { Job ENodeB
json:"parenteNodeB"SubNetworkjson:"subnetwork"EranConnectionjson:"eranConnection"Nodesjson:"nodes"BaselineId int }// GetName returns job eNodeB name func (job *ElasticRan) GetName() string { var names []string for _, node := range job.Nodes { names = append(names, node.ENodeB.Site.Cellular.Name) } return strings.Join(names, ", ") }
// GetSubType returns job eNodeB subtype func (job *ElasticRan) GetSubType() string { var subTypes []string for _, node := range job.Nodes { subTypes = append(subTypes, node.ENodeB.Site.Cellular.SubType) } return strings.Join(subTypes, ", ") }
- User
I have Nodes model: package model
import ( validation “github.com/go-ozzo/ozzo-validation/v4” )
// Node is custom type that represents *model.ENodeB and *model.EUtranCellData // of cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is custom type that represents map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err } return nil }
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { for name, node := range *nodes { if err := node.ValidateNode(); err != nil { return validation.Errors{ name: err, } } } return nil }
Now correct following code, so func GetName, would run for each eNodeB in Node
package model
// Eranintegrjob is custom type that holds all job required // for Eran integration type ElasticRan struct { Job ENodeB
json:"parenteNodeB"SubNetworkjson:"subnetwork"EranConnectionjson:"eranConnection"Nodesjson:"nodes"BaselineId int } - Assistant
package model
// Eranintegrjob is custom type that holds all job required // for Eran integration type ElasticRan struct { Job ENodeB
json:"parenteNodeB"SubNetworkjson:"subnetwork"EranConnectionjson:"eranConnection"Nodesjson:"nodes"BaselineId int }// GetName returns job eNodeB names func (job *ElasticRan) GetNames() []string { var names []string for _, node := range job.Nodes { names = append(names, node.ENodeB.Site.Cellular.Name) } return names }
- User
correct js code // draw EUtranCells of first cosite Node Object.keys(data['nodes']).forEach(node => { const sec = document.createElement('section') sec.appendChild(draw.eUtranCoCells(data[node].cells)) form.appendChild(sec)
- Assistant
// draw EUtranCells of the first cosite Node const nodes = Object.keys(data['nodes']); const firstNode = nodes[0]; const sec = document.createElement('section'); sec.appendChild(draw.eUtranCoCells(data[firstNode].cells)); form.appendChild(sec);
- User
fix code package model
import ( validation "github.com/go-ozzo/ozzo-validation/v4" )
// Node is custom type that represents *model.ENodeB and *model.EUtranCellData // of cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is custom type that represents map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err return nil}
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { for name, node := range *nodes { if err := node.ValidateNode(); err != nil { return validation.Errors{ name: err, } } } return nil }
- Assistant
import ( validation "github.com/go-ozzo/ozzo-validation/v4" )
// Node is a custom type that represents *model.ENodeB and *model.EUtranCellData // of a cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is a custom type that represents a map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with an integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err } return nil}
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { errs := validation.Errors{} for name, node := range *nodes { if err := node.ValidateNode(); err != nil { errs[name] = err } }
if len(errs) > 0 { return errs } return nil}
- User
fix Validate function so it use ValidateNode function for each node package model
import ( validation "github.com/go-ozzo/ozzo-validation/v4" )
// Node is custom type that represents *model.ENodeB and *model.EUtranCellData // of cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is custom type that represents map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err return nil}
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { for name, node := range *nodes { if err := node.ValidateNode(); err != nil { return validation.Errors{ name: err, } } } return nil }
- Assistant
import ( validation "github.com/go-ozzo/ozzo-validation/v4" )
// Node is a custom type that represents *model.ENodeB and *model.EUtranCellData // of a cosite Node for Elastic Ran type Node struct { ENodeB *ENodeB EUtranCellData *EUtranCellData }
// Nodes is a custom type that represents a map of *model.Node type Nodes map[string]*Node
// ValidateNode validates EnodeB naming and cells data coming with an integration request func (node *Node) ValidateNode() error { if err := node.ENodeB.ValidateMEv2(); err != nil { return err }
if err := node.EUtranCellData.ValidateCells(); err != nil { return err } return nil}
// ValidateNodes validates the Nodes func (nodes *Nodes) Validate() error { errs := make(validation.Errors) for name, node := range *nodes { if err := node.ValidateNode(); err != nil { errs[name] = err } }
if len(errs) > 0 { return errs } return nil}