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

Added filters to hiearachy

parent 98cd78b5
No related branches found
No related tags found
1 merge request!1Big merge
......@@ -49,7 +49,7 @@ func (s *Service) ConvertQuery(JSONQuery *entity.IncomingQueryJSON) (*string, er
return nil, errors.New("non-existing relation referenced in return")
}
}
//search(JSONQuery)
search(JSONQuery)
result := createQuery(JSONQuery)
return result, nil
}
......
......@@ -43,6 +43,8 @@ func search(JSONQuery *entity.IncomingQueryJSON) {
}
fmt.Println("")
}
AddFilters(JSONQuery)
fmt.Println(listoflists)
}
......@@ -369,6 +371,59 @@ func FuncToAllRel(JSONQuery *entity.IncomingQueryJSON, function pdict) {
}
}
func AddFilters(JSONQuery *entity.IncomingQueryJSON) {
filterDone := make([]bool, len(JSONQuery.Filters))
for i, filter := range JSONQuery.Filters {
if !filterDone[i] {
p := pdict{
typename: filter.FilteredType,
pointer: filter.FilteredID,
}
f := pdict{
typename: "filter",
pointer: filter.ID,
}
addOneFilter(f, JSONQuery, p, &filterDone)
}
}
}
func addOneFilter(filterPDict pdict, JSONQuery *entity.IncomingQueryJSON, p pdict, filterDone *[]bool) {
if p.typename == "filter" && (*filterDone)[p.pointer] {
l := FindCurrentLayer(listoflists, p)
k := [1]pdict{}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
BelowAppend(l, k)
}
(*filterDone)[filterPDict.pointer] = true
} else if p.typename == "filter" {
pnew := pdict{
typename: JSONQuery.Filters[p.pointer].FilteredType,
pointer: JSONQuery.Filters[p.pointer].FilteredID,
}
addOneFilter(p, JSONQuery, pnew, filterDone)
l := FindCurrentLayer(listoflists, p)
k := [1]pdict{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
BelowAppend(l, k)
}
(*filterDone)[filterPDict.pointer] = true
} else {
l := FindCurrentLayer(listoflists, p)
k := [1]pdict{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].typename == "filter" {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
BelowAppend(l, k)
}
(*filterDone)[filterPDict.pointer] = true
}
}
// TODO
// Write a function that appends 1 level above
func AboveAppend() {
......
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