Skip to content

Commit

Permalink
fixed missed rel in save
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Solender committed Dec 15, 2019
1 parent 11b8527 commit 8460272
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions save.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,32 +644,53 @@ func parseStruct(parentId, edgeLabel string, parentIsStart bool, direction dsl.D
}

//set edge
if parentId != "" && parentIsStart {
if parentId != "" {
if _, ok := (*relationsPtr)[edgeLabel]; !ok {
(*relationsPtr)[edgeLabel] = []relCreateConf{}
}

start := ""
end := ""
curDir := direction

//if parentIsStart {
start = parentId
end = id
//} else {
// start = id
// end = parentId
//}
if parentIsStart {
start = parentId
end = id
} else {
start = id
end = parentId

if curDir == dsl.DirectionIncoming {
curDir = dsl.DirectionOutgoing
} else if curDir == dsl.DirectionOutgoing {
curDir = dsl.DirectionIncoming
}
}

if edgeParams == nil {
edgeParams = map[string]interface{}{}
}

(*relationsPtr)[edgeLabel] = append((*relationsPtr)[edgeLabel], relCreateConf{
Direction: direction,
Params: edgeParams,
StartNodeUUID: start,
EndNodeUUID: end,
})
found := false

//check if this edge is already here
if len((*relationsPtr)[edgeLabel]) != 0 {
for _, conf := range (*relationsPtr)[edgeLabel] {
if conf.StartNodeUUID == start && conf.EndNodeUUID == end {
found = true
}
}
}

if !found {
(*relationsPtr)[edgeLabel] = append((*relationsPtr)[edgeLabel], relCreateConf{
Direction: curDir,
Params: edgeParams,
StartNodeUUID: start,
EndNodeUUID: end,
})
}

}

//check if this has been visited yet, do this after edge is intentional
Expand Down

0 comments on commit 8460272

Please sign in to comment.