New class link to handle links between components and possible errors

This commit is contained in:
pb
2024-04-16 16:12:54 +02:00
parent 99278ff7ef
commit d91afc2acd
5 changed files with 240 additions and 100 deletions

View File

@@ -41,15 +41,35 @@ type MxObject struct {
// Didn't manage to differentiate Links and cells containing components using
// only structures and unmarshal, so we use this method post-umarshalling
func (g *MxGraphModel) createLinks() error {
func (g *MxGraphModel) createLinks() {
var cells_without_links []MxCell
for i, mxcell := range g.Root.MxCell {
if mxcell.Edge != nil {
if mxcell.Edge != nil {
mxcell.processLinks()
newLink := MxLink{mxcell.ID,*mxcell.Source,*mxcell.Target}
g.Root.MxLink = append(g.Root.MxLink,newLink)
g.Root.MxCell = append(g.Root.MxCell[:i],g.Root.MxCell[i+1:]...)
} else {
cells_without_links = append(cells_without_links,g.Root.MxCell[i])
}
}
return nil
g.Root.MxCell = nil
g.Root.MxCell = cells_without_links
}
func (cell *MxCell) processLinks() {
v := ""
if cell.Source == nil {
cell.Source = &v
}
if cell.Target == nil {
cell.Target = &v
}
}
type mxissue struct {