retrieve Links
This commit is contained in:
33
graph.go
33
graph.go
@@ -20,11 +20,11 @@ type Link struct {
|
||||
}
|
||||
|
||||
type Graph struct {
|
||||
Links []Link
|
||||
Datas []models.DataModel
|
||||
Computings []models.ComputingModel
|
||||
Datacenters []models.DatacenterModel
|
||||
Storages []models.StorageModel
|
||||
Links []models.Link
|
||||
ws HttpQuery
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ func (g *Graph) LoadFrom(workspace string) error {
|
||||
// fmt.Printf("Many: %v", v)
|
||||
}
|
||||
|
||||
dictionnary := make(map[string]string)
|
||||
// dictionnary := make(map[string]string)
|
||||
var idlinks []Link
|
||||
|
||||
g.GetWorkflowComponents(workspace)
|
||||
|
||||
g.GetLinks(workspace)
|
||||
|
||||
for _, element := range cells {
|
||||
// id := element["@id"].(string)
|
||||
@@ -126,10 +126,10 @@ func (g *Graph) LoadFrom(workspace string) error {
|
||||
}
|
||||
|
||||
// translate links
|
||||
for _, link := range idlinks {
|
||||
g.Links = append(g.Links, Link{Src: dictionnary[link.Src], Dst: dictionnary[link.Dst]})
|
||||
fmt.Println("Link: " + link.Src + " " + link.Dst + " : " + dictionnary[link.Src] + " " + dictionnary[link.Dst])
|
||||
}
|
||||
// for _, link := range idlinks {
|
||||
// g.Links = append(g.Links, Link{Src: dictionnary[link.Src], Dst: dictionnary[link.Dst]})
|
||||
// fmt.Println("Link: " + link.Src + " " + link.Dst + " : " + dictionnary[link.Src] + " " + dictionnary[link.Dst])
|
||||
// }
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -186,6 +186,25 @@ func (g *Graph) GetWorkflowComponents(workflow string){
|
||||
|
||||
}
|
||||
|
||||
func (g *Graph) GetLinks(workflow string){
|
||||
|
||||
result := gjson.Get(workflow, "link")
|
||||
|
||||
if (result.Type != gjson.Null) {
|
||||
result.ForEach(func(id, value gjson.Result) bool{
|
||||
var l models.Link
|
||||
fmt.Print(id)
|
||||
fmt.Println(value.Str)
|
||||
|
||||
json.Unmarshal([]byte(value.Raw),&l)
|
||||
|
||||
g.Links = append(g.Links, l)
|
||||
fmt.Println(l)
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Graph) AddDataModel(id string, user_input gjson.Result, wf_id string) error {
|
||||
var d models.DataModel
|
||||
resp, err := g.ws.Get("v1/data/" + id)
|
||||
|
||||
Reference in New Issue
Block a user