/*
This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course.
© Copyright Utrecht University (Department of Information and Computing Sciences)
*/

package aql

import (
	"fmt"
	"strconv"

	"git.science.uu.nl/graphpolaris/query-conversion/entity"
)

// Version 1.13

/*
ConvertQuery converts an IncomingQueryJSON object into AQL
	JSONQuery: *entity.IncomingQueryJSON, the query to be converted to AQL
	Returns: *string, the AQL query and a possible error
*/
func (s *Service) ConvertQuery(JSONQuery *entity.IncomingQueryJSON) (*string, error) {
	// Check to make sure all indexes exist
	// The largest possible id for an entity
	shitlist, _ := createHierarchy(JSONQuery)
	for i, tree := range shitlist {
		fmt.Println("I am triple(from,rel,to): " + strconv.Itoa(tree.Self.FromNode.ID) + "," + strconv.Itoa(tree.Self.Rel.ID) + "," + strconv.Itoa(tree.Self.ToNode.ID))
		fmt.Println("My relation contains the following nodes(from,to): " + strconv.Itoa(tree.Self.Rel.FromID) + "," + strconv.Itoa(tree.Self.Rel.ToID))
		fmt.Println("My index is: " + strconv.Itoa(i))
		fmt.Println("My parent index is: " + strconv.Itoa(tree.Parent))
		fmt.Println("My children's indices are: ")
		for j := range tree.Children {
			fmt.Println(tree.Children[j])
		}
		fmt.Println("Next please!")
	}
	result := ""
	return &result, nil

}