From 6a830014f8577ca594bb1f098501bbc827894a22 Mon Sep 17 00:00:00 2001 From: Kurt Nordstrom Date: Wed, 1 Jul 2026 15:49:01 -0400 Subject: [PATCH 1/2] Add cql fields for 'type' and 'parent' --- api/entries.go | 8 ++++++++ test/entries_test.go | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/api/entries.go b/api/entries.go index baa432f..87374f1 100644 --- a/api/entries.go +++ b/api/entries.go @@ -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() + f.SetColumn("e.parent") + def.AddField("parent", f) + var parser cql.Parser query, err := parser.Parse(cqlString) if err != nil { diff --git a/test/entries_test.go b/test/entries_test.go index 920542f..c3a5bce 100644 --- a/test/entries_test.go +++ b/test/entries_test.go @@ -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, @@ -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, From 6f08498d5282690d2e9ebb32a7e2767759acf106 Mon Sep 17 00:00:00 2001 From: Kurt Nordstrom Date: Wed, 1 Jul 2026 15:53:18 -0400 Subject: [PATCH 2/2] Add new fixtures --- .../entries-cql-parent.get.res.json | 108 ++++++++++++++++++ .../apifixtures/entries-cql-type.get.res.json | 20 ++++ 2 files changed, 128 insertions(+) create mode 100644 test/apifixtures/entries-cql-parent.get.res.json create mode 100644 test/apifixtures/entries-cql-type.get.res.json diff --git a/test/apifixtures/entries-cql-parent.get.res.json b/test/apifixtures/entries-cql-parent.get.res.json new file mode 100644 index 0000000..aa6086d --- /dev/null +++ b/test/apifixtures/entries-cql-parent.get.res.json @@ -0,0 +1,108 @@ +{ + "items": [ + "<>", + { + "id": "00000000-0000-0000-0000-000000000002", + "name": "An Institution", + "contactName":"Bob", + "type":"Institution", + "parent":"00000000-0000-0000-0000-000000000004", + "symbols": [ + "<>", + { + "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": [ + "<>", + { + "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 + } +} diff --git a/test/apifixtures/entries-cql-type.get.res.json b/test/apifixtures/entries-cql-type.get.res.json new file mode 100644 index 0000000..874cf1f --- /dev/null +++ b/test/apifixtures/entries-cql-type.get.res.json @@ -0,0 +1,20 @@ +{ + "items": [ + "<>", + { + "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 + } +}