Skip to content
Snippets Groups Projects
Commit 6129692e authored by Jonge,J. de (Joes)'s avatar Jonge,J. de (Joes)
Browse files

Merge branch '676-Query-Nesting-Development' of...

Merge branch '676-Query-Nesting-Development' of https://git.science.uu.nl/GravenvanPolaris/query-conversion into 676-Query-Nesting-Development
parents 3ea1b8a6 b4e2d678
No related branches found
No related tags found
1 merge request!1Big merge
...@@ -391,7 +391,7 @@ func AddFilters(JSONQuery *entity.IncomingQueryJSON) { ...@@ -391,7 +391,7 @@ func AddFilters(JSONQuery *entity.IncomingQueryJSON) {
func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdict, filterDone *[]bool) { func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdict, filterDone *[]bool) {
if p.typename == "filter" && (*filterDone)[p.pointer] { if p.typename == "filter" && (*filterDone)[p.pointer] {
l := FindCurrentLayer(listoflists, p) l := FindCurrentLayer(listoflists, p)
k := [1]pdict{} k := []pdict{}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" { if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict) listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else { } else {
...@@ -405,7 +405,7 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic ...@@ -405,7 +405,7 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic
} }
addOneFilter(p, JSONQuery, pnew, filterDone) addOneFilter(p, JSONQuery, pnew, filterDone)
l := FindCurrentLayer(listoflists, p) l := FindCurrentLayer(listoflists, p)
k := [1]pdict{filterPDict} k := []pdict{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" { if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict) listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else { } else {
...@@ -414,7 +414,7 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic ...@@ -414,7 +414,7 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic
(*filterDone)[filterPDict.pointer] = true (*filterDone)[filterPDict.pointer] = true
} else { } else {
l := FindCurrentLayer(listoflists, p) l := FindCurrentLayer(listoflists, p)
k := [1]pdict{filterPDict} k := []pdict{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" { if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict) listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else { } else {
...@@ -424,16 +424,22 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic ...@@ -424,16 +424,22 @@ func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdic
} }
} }
// TODO // A function that appends 1 level above (if index is 0 this won't work)
// Write a function that appends 1 level above func AboveAppend(index int, value []pdict) [][]pdict {
func AboveAppend() { if index == 0 {
return prepend(listoflists, value)
}
return BelowAppend(index-1, value)
} }
// TODO // A function that appends 1 level below (thanks to wasmup on stackoverflow)
// Write a function that appends 1 level below func BelowAppend(index int, value []pdict) [][]pdict {
func BelowAppend() { if len(listoflists) == index { // nil or empty slice or after last element
return append(listoflists, value)
}
listoflists = append(listoflists[:index+1], listoflists[index:]...) // index < len(a)
listoflists[index] = value
return listoflists
} }
// A simple double-for loop that finds the layer in which an element resides in the hierarchy // A simple double-for loop that finds the layer in which an element resides in the hierarchy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment