Skip to content
Snippets Groups Projects
Commit 638f7a9e authored by Geurtjens,D. (Douwe Geurtjens)'s avatar Geurtjens,D. (Douwe Geurtjens)
Browse files

Quick push new new format

parent 700b62c2
No related branches found
No related tags found
1 merge request!1Big merge
......@@ -13,7 +13,7 @@ isRelation is a boolean specifying if this constraint comes from a node or relat
Return: a string containing a FILTER-statement with all the constraints
*/
func createConstraintStatements(constraints *[]entity.QueryFilterStruct, name string, isRelation bool) *string {
func createConstraintStatements(constraints *[]entity.QueryConstraintStruct, name string, isRelation bool) *string {
s := ""
if len(*constraints) == 0 {
return &s
......@@ -38,7 +38,7 @@ isRelation is a boolean specifying if this constraint comes from a node or relat
Return: a string containing an boolean expression of a single constraint
*/
func createConstraintBoolExpression(constraint *entity.QueryFilterStruct, name string, isRelation bool) *string {
func createConstraintBoolExpression(constraint *entity.QueryConstraintStruct, name string, isRelation bool) *string {
var (
match string
value string
......
......@@ -43,7 +43,6 @@ func search(JSONQuery *entity.IncomingQueryJSON, index int) []entity.PdictList {
}
fmt.Println("")
}
listoflists = addFilters(JSONQuery, listoflists)
fmt.Println(listoflists)
return listoflists
}
......@@ -273,52 +272,6 @@ func funcToAllRel(JSONQuery *entity.IncomingQueryJSON, listoflists []entity.Pdic
return listoflists
}
func addFilters(JSONQuery *entity.IncomingQueryJSON, listoflists []entity.PdictList) []entity.PdictList {
for i, filter := range JSONQuery.Filters {
if _, ok := filterDone[i]; !ok {
p := makePdict(filter.FromType, filter.FromID)
f := makePdict(FILTERSTRING, filter.ID)
listoflists = addOneFilter(f, JSONQuery, listoflists, p, &filterDone)
}
}
return listoflists
}
func addOneFilter(filterPDict entity.Pdict, JSONQuery *entity.IncomingQueryJSON, listoflists []entity.PdictList, p entity.Pdict, filterDone *map[int]bool) []entity.PdictList {
if p.Typename == FILTERSTRING && (*filterDone)[p.Pointer] {
l := findCurrentLayer(listoflists, p)
k := entity.PdictList{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].Typename == FILTERSTRING {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
listoflists = filterAppend(listoflists, l, k)
}
(*filterDone)[filterPDict.Pointer] = true
} else if p.Typename == FILTERSTRING {
pnew := makePdict(JSONQuery.Filters[p.Pointer].FromType, JSONQuery.Filters[p.Pointer].FromID)
addOneFilter(p, JSONQuery, listoflists, pnew, filterDone)
l := findCurrentLayer(listoflists, p)
k := entity.PdictList{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].Typename == FILTERSTRING {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
listoflists = filterAppend(listoflists, l, k)
}
(*filterDone)[filterPDict.Pointer] = true
} else {
l := findCurrentLayer(listoflists, p)
k := entity.PdictList{filterPDict}
if len(listoflists) > l+1 && listoflists[l+1][0].Typename == FILTERSTRING {
listoflists[l+1] = append(listoflists[l+1], filterPDict)
} else {
listoflists = filterAppend(listoflists, l, k)
}
(*filterDone)[filterPDict.Pointer] = true
}
return listoflists
}
// A function that appends 1 level above (if index is 0 this won't work)
func aboveAppend(listoflists []entity.PdictList, index int, values entity.PdictList) []entity.PdictList {
if index == 0 {
......@@ -349,19 +302,6 @@ func belowAppend(listoflists []entity.PdictList, index int, values entity.PdictL
}
}
func filterAppend(listoflists []entity.PdictList, index int, values entity.PdictList) []entity.PdictList {
if len(listoflists)-1 == index { // nil or empty slice or after last element
return append(listoflists, values)
}
k := make([]entity.PdictList, len(listoflists[index+1:]))
copy(k, listoflists[index+1:])
l := make([]entity.PdictList, len(listoflists[:index+1]))
copy(l, listoflists[:index+1])
listoflists = append(l, values) // index < len(a)
return append(listoflists, k...)
}
// A simple double-for loop that finds the layer in which an element resides in the hierarchy
// Because we only append elements relative to another element, we can freely use this to keep track of layers
func findCurrentLayer(list []entity.PdictList, element entity.Pdict) int {
......
......@@ -7,7 +7,6 @@ type IncomingQueryJSON struct {
Entities []QueryEntityStruct
Relations []QueryRelationStruct
GroupBys []QueryGroupByStruct
Filters []QueryFilterStruct
MachineLearning []QueryMLStruct
// Limit is for limiting the amount of paths AQL will return in a relation let statement
Limit int
......@@ -24,19 +23,21 @@ type QueryReturnStruct struct {
// QueryEntityStruct encapsulates a single entity with its corresponding constraints
type QueryEntityStruct struct {
ID int
Name string
ID int
Name string
Constraints []QueryConstraintStruct
}
// QueryRelationStruct encapsulates a single relation with its corresponding constraints
type QueryRelationStruct struct {
ID int
Name string
FromType string
FromID int
ToType string
ToID int
Depth QuerySearchDepthStruct
ID int
Name string
FromType string
FromID int
ToType string
ToID int
Depth QuerySearchDepthStruct
QueryConstraintStruct []QueryConstraintStruct
}
type QueryGroupByStruct struct {
......@@ -49,20 +50,21 @@ type QueryGroupByStruct struct {
ByAttribute string
AppliedModifier string
RelationID int
Constraints []QueryConstraintStruct
}
type QueryFilterStruct struct {
ID int
FromType string
FromID int
ToType string
ToID int
// QueryConstraintStruct holds the information of the constraint
// Constraint datatypes
// string MatchTypes: exact/contains/startswith/endswith
// int MatchTypes: GT/LT/EQ
// bool MatchTypes: EQ/NEQ
type QueryConstraintStruct struct {
Attribute string
Value string
DataType string
MatchType string
Value string
InType string
InID int
InType string
}
type QueryMLStruct struct {
......@@ -83,9 +85,3 @@ type QuerySearchDepthStruct struct {
Min int
Max int
}
// QueryConstraintStruct holds the information of the constraint
// Constraint datatypes
// string MatchTypes: exact/contains/startswith/endswith
// int MatchTypes: GT/LT/EQ/
// bool MatchTypes: EQ/NEQ
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