Skip to content
Snippets Groups Projects
Commit 8921001a authored by thijsheijden's avatar thijsheijden
Browse files

Fixed cypher converted

parent 7265311a
Branches
No related tags found
No related merge requests found
Pipeline #115062 failed
......@@ -5,11 +5,13 @@ This program has been developed by students from the bachelor Computer Science a
package aql
import "git.science.uu.nl/graphpolaris/query-conversion"
// Service implements the QueryConverter interface (in the query service)
type Service struct {
}
// NewService creates a new AQL conversion service
func NewService() *Service {
func NewService() query.Converter {
return &Service{}
}
......@@ -14,7 +14,7 @@ import (
)
// ConvertQuery takes the json from the visual query builder and converts it into Cypher
func (s *Service) ConvertQuery(totalJSONQuery *entity.IncomingQueryJSON) (*string, error) {
func (s *Service) ConvertQuery(totalJSONQuery *entity.IncomingQueryJSON) (*string, *[]byte, error) {
var finalCypher *string
queryJSON := totalJSONQuery
......@@ -23,20 +23,20 @@ func (s *Service) ConvertQuery(totalJSONQuery *entity.IncomingQueryJSON) (*strin
query, _, _ := checkForQueryCluster(queryJSON)
if query == nil {
return nil, errors.New("Invalid query")
return nil, nil, errors.New("Invalid query")
}
ok, err := checkNoDeadEnds(query)
if !ok {
return nil, err
return nil, nil, err
}
finalCypher, err = createCypher(query)
if err != nil {
return nil, err
return nil, nil, err
}
return finalCypher, nil
return finalCypher, nil, nil
}
// createCypher translates a cluster of nodes (query) to Cypher
......
......
......@@ -111,7 +111,7 @@ func TestGroupBy(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -216,7 +216,7 @@ func TestSmallChain(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -393,7 +393,7 @@ func TestLargeQueryChain(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -519,7 +519,7 @@ func TestInStatement(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -632,7 +632,7 @@ func TestMultipleByStatementDisconnected(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -752,7 +752,7 @@ func TestDoubleInStatement(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -839,7 +839,7 @@ func TestEndOnGroupBy(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -910,7 +910,7 @@ func TestSimpleQuery(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -962,7 +962,7 @@ func TestNoRelation(t *testing.T) {
fmt.Println(" ")
s := NewService()
_, err := s.ConvertQuery(&JSONQuery)
_, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
assert.Equal(t, err.Error(), "Invalid query")
} else {
......@@ -1012,7 +1012,7 @@ func TestNoEntities(t *testing.T) {
fmt.Println(" ")
s := NewService()
_, err := s.ConvertQuery(&JSONQuery)
_, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
assert.Equal(t, err.Error(), "Invalid query")
} else {
......@@ -1085,7 +1085,7 @@ func TestTwoRelationsCycle(t *testing.T) {
fmt.Println(" ")
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
t.Fail()
......@@ -1215,7 +1215,7 @@ func TestCyclePlusDependency(t *testing.T) {
fmt.Println(" ")
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
t.Fail()
......@@ -1330,7 +1330,7 @@ func TestTripleCycle(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
assert.Equal(t, err, errors.New("Cyclic query detected"))
......@@ -1436,7 +1436,7 @@ func TestMultipleByStatementConnected(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......@@ -1584,7 +1584,7 @@ func TestRelationOnGroupBy(t *testing.T) {
json.Unmarshal(query, &JSONQuery)
s := NewService()
cypher, err := s.ConvertQuery(&JSONQuery)
cypher, _, err := s.ConvertQuery(&JSONQuery)
if err != nil {
fmt.Println(err)
}
......
......
......@@ -5,6 +5,8 @@ This program has been developed by students from the bachelor Computer Science a
package cypher
import "git.science.uu.nl/graphpolaris/query-conversion"
/*
Service implements the QueryConverter interface (in the query service)
*/
......@@ -15,6 +17,6 @@ type Service struct {
NewService creates a new Cypher conversion service
Return: *Service, the new service
*/
func NewService() *Service {
func NewService() query.Converter {
return &Service{}
}
......@@ -4,11 +4,13 @@ This program has been developed by students from the bachelor Computer Science a
*/
package sparql
import "git.science.uu.nl/graphpolaris/query-conversion"
// Service implements the QueryConverter interface (in the query service)
type Service struct {
}
// NewService creates a new AQL conversion service
func NewService() *Service {
func NewService() query.Converter {
return &Service{}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment