Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ func handleEntryCQL(cqlString string, noBaseArgs int) (pgcql.Query, error) {
f.SetColumn("e.description")
def.AddField("description", f)

f = pgcql.NewFieldString().WithLikeOps()
f.SetColumn("e.type")
def.AddField("type", f)

f = pgcql.NewFieldString().WithExact()
Comment thread
kurtnordstrom marked this conversation as resolved.
f.SetColumn("e.parent")
def.AddField("parent", f)

var parser cql.Parser
query, err := parser.Parse(cqlString)
if err != nil {
Expand Down
108 changes: 108 additions & 0 deletions test/apifixtures/entries-cql-parent.get.res.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"items": [
"<<UNORDERED>>",
{
"id": "00000000-0000-0000-0000-000000000002",
"name": "An Institution",
"contactName":"Bob",
"type":"Institution",
"parent":"00000000-0000-0000-0000-000000000004",
"symbols": [
"<<UNORDERED>>",
{
"authority": "TEST",
"id": "60000000-0000-0000-0000-000000000001",
"symbol": "ANINST"
},
{
"authority": "TEST",
"id": "60000000-0000-0000-0000-000000000002",
"symbol": "ANINSTTOO"
}
],
"endpoints": [
{
"id": "00000000-0000-0000-0000-000000000001",
"name": "Primary",
"type": "ISO18626",
"address": "https://whatever.host.tld/path"
}
],
"lmsConfig": {
"address":"https://also.not.real",
"fromAgency":"rivendell",
"fromAgencyAuthentication":"pack_extra_lembas",
"acceptItemEnabled": true
},
"closures": [
{
"entry":"00000000-0000-0000-0000-000000000002",
"id":"70000000-0000-0000-0000-000000000001",
"reason":"Winter break",
"startDate":"2024-01-01",
"endDate":"2024-01-15"
}
]
},
{
"id": "00000000-0000-0000-0000-000000000003",
"name": "Eine Weitere Einrichtung",
"contactName": "Klaus",
"type":"Institution",
"parent":"00000000-0000-0000-0000-000000000004",
"addresses": [
"<<UNORDERED>>",
{
"id": "00000003-0000-0000-0000-000000000001",
"type": "Default",
"addressComponents": [
{"seq": 0, "type": "Thoroughfare", "value": "Unter den Linden 1"},
{"seq": 1, "type": "Locality", "value": "Berlin"},
{"seq": 2, "type": "PostalCode", "value": "10117"},
{"seq": 3, "type": "CountryCode", "value": "DE"}
]
},
{
"id": "00000003-0000-0000-0000-000000000002",
"type": "Billing",
"addressComponents": [
{"seq": 0, "type": "Thoroughfare", "value": "Musterstraße 99"},
{"seq": 1, "type": "Locality", "value": "München"},
{"seq": 2, "type": "PostalCode", "value": "80331"}
]
}
]
},
{
"id": "00000000-0000-0000-0000-000000000001",
"name": "No Symbol",
"description": "A very particular test entry",
"type":"Institution",
"parent":"00000000-0000-0000-0000-000000000004",
"networks": [
{
"id":"20000000-0000-0000-0000-000000000001","consortium":"00000000-0000-0000-0000-000000000004",
"name":"The Ultimate Network","priority":0.0
},
{
"id":"20000000-0000-0000-0000-000000000003","consortium":"00000000-0000-0000-0000-000000000004",
"name": "The Completely Normal Network","priority":0.0
}
],
"tiers":[
{
"id":"30000000-0000-0000-0000-000000000001","consortium":"00000000-0000-0000-0000-000000000004",
"name":"Top Tier","level":"standard","type":"loan","cost":0.0
}
],
"lmsConfig": {
"address":"https://not.really.real",
"fromAgency":"diku",
"fromAgencyAuthentication":""
}
}
],
"about": {
"count": 3
}
}
20 changes: 20 additions & 0 deletions test/apifixtures/entries-cql-type.get.res.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"items": [
"<<UNORDERED>>",
{
"id": "00000000-0000-0000-0000-000000000004",
"name": "Das Konsortium",
"type":"Consortium",
"symbols": [
{
"authority": "TEST",
"id": "60000000-0000-0000-0000-000000000003",
"symbol": "ANCONS"
}
]
}
],
"about": {
"count": 1
}
}
16 changes: 16 additions & 0 deletions test/entries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ func TestEntryCases(t *testing.T) {
resFile: "entries-cql-name.get.res.json",
addlHeaders: institutionPermissionHeaders,
},
{
name: "GET entries with CQL query by parent",
method: http.MethodGet,
endpoint: "/entries?q=parent%3D00000000-0000-0000-0000-000000000004",
status: http.StatusOK,
resFile: "entries-cql-parent.get.res.json",
addlHeaders: institutionPermissionHeaders,
},
{
name: "GET entries with CQL wildcard query by description",
method: http.MethodGet,
Expand All @@ -138,6 +146,14 @@ func TestEntryCases(t *testing.T) {
status: http.StatusBadRequest,
addlHeaders: institutionPermissionHeaders,
},
{
name: "GET entries with CQL query by type",
method: http.MethodGet,
endpoint: "/entries?q=type%3DConsortium",
status: http.StatusOK,
resFile: "entries-cql-type.get.res.json",
addlHeaders: institutionPermissionHeaders,
},
{
name: "POST entry",
method: http.MethodPost,
Expand Down
Loading