func ReadDesign(name, owner string) (*addie.Design, error) { key, err := ReadDesignKey(name, owner) if err != nil { return nil, readFailure(err) } dsg := addie.EmptyDesign(name) //we are going to go from the top down, grabbing all of the systems //and then grabbing the components of the systems q := fmt.Sprintf("SELECT id FROM systems WHERE design_id = %d", key) rows, err := runQ(q) defer safeClose(rows) if err != nil { return nil, selectFailure(err) } for rows.Next() { var sys_key int err := rows.Scan(&sys_key) if err != nil { return nil, scanFailure(err) } //computers computers, err := ReadSystemComputers(sys_key) if err != nil { return nil, readFailure(err) } for _, c := range computers { dsg.Elements[c.Id] = c } //switches switches, err := ReadSystemSwitches(sys_key) if err != nil { return nil, readFailure(err) } for _, s := range switches { dsg.Elements[s.Id] = s } //routers routers, err := ReadSystemRouters(sys_key) if err != nil { return nil, readFailure(err) } for _, r := range routers { dsg.Elements[r.Id] = r } //links links, err := ReadSystemLinks(sys_key) if err != nil { return nil, readFailure(err) } for _, l := range links { dsg.Elements[l.Id] = l } //phyos phyos, err := ReadSystemPhyos(sys_key) if err != nil { return nil, readFailure(err) } for _, p := range phyos { dsg.Elements[p.Id] = p } //saxs saxs, err := ReadSystemSaxs(sys_key) if err != nil { return nil, readFailure(err) } for _, s := range saxs { dsg.Elements[s.Id] = s } //plinks plinks, err := ReadSystemPlinks(sys_key) if err != nil { return nil, readFailure(err) } for _, p := range plinks { dsg.Elements[p.Id] = p } } return &dsg, nil }
func loadDesign(id string) { design = addie.EmptyDesign(id) }