Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix external authorities handling #60

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Compiled source #
/public-concordances-api

vendor/*/
.vscode
6 changes: 6 additions & 0 deletions concordances/cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

const thingURL = "http://api.ft.com/things/"
const systemURL = "http://api.ft.com/system/"

// Driver interface
type Driver interface {
Expand All @@ -31,6 +32,11 @@ func NewCypherDriver(driver *cmneo4j.Driver, publicAPIURL string) (CypherDriver,
return CypherDriver{}, err
}

conceptTypes := ontology.GetConfig().GetExternalAuthorities()
for _, conceptType := range conceptTypes {
authorityMap[conceptType] = systemURL + conceptType
}

return CypherDriver{driver, publicAPIURL}, nil
}

Expand Down
96 changes: 96 additions & 0 deletions concordances/cypher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,74 @@ var expectedConcordanceNAICSIndustryClassificationByAuthority = Concordances{
},
}

var expectedConcordanceSVProvision = Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/1808c3fc-04bb-589b-a457-640bffa8f6c6",
APIURL: "http://api.ft.com/concepts/1808c3fc-04bb-589b-a457-640bffa8f6c6"},
Identifier{
Authority: "http://api.ft.com/system/UPP",
IdentifierValue: "1808c3fc-04bb-589b-a457-640bffa8f6c6"},
},
{
Concept{
ID: "http://api.ft.com/things/1808c3fc-04bb-589b-a457-640bffa8f6c6",
APIURL: "http://api.ft.com/concepts/1808c3fc-04bb-589b-a457-640bffa8f6c6"},
Identifier{
Authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
IdentifierValue: "65d735ebad5f88460e919a42"},
},
},
}

var expectedConcordanceSVProvisionByAuthority = Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/1808c3fc-04bb-589b-a457-640bffa8f6c6",
APIURL: "http://api.ft.com/concepts/1808c3fc-04bb-589b-a457-640bffa8f6c6"},
Identifier{
Authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
IdentifierValue: "65d735ebad5f88460e919a42"},
},
},
}

var expectedConcordanceSVCategory = Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366",
APIURL: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
Identifier{
Authority: "http://api.ft.com/system/UPP",
IdentifierValue: "e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
},
{
Concept{
ID: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366",
APIURL: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
Identifier{
Authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
IdentifierValue: "e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
},
},
}

var expectedConcordanceSVCategoryByAuthority = Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366",
APIURL: "http://api.ft.com/things/e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
Identifier{
Authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
IdentifierValue: "e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
},
},
}

func TestNeoReadByConceptID(t *testing.T) {
driver := getNeoDriver(assert.New(t))

Expand Down Expand Up @@ -353,6 +421,20 @@ func TestNeoReadByConceptID(t *testing.T) {
expectedLen: 3,
expected: expectedConcordanceNAICSIndustryClassification,
},
{
name: "SVProvision",
fixture: "SVProvision-Unconcorded-1808c3fc-04bb-589b-a457-640bffa8f6c6.json",
conceptIDs: []string{"1808c3fc-04bb-589b-a457-640bffa8f6c6"},
expectedLen: 2,
expected: expectedConcordanceSVProvision,
},
{
name: "SVCategory",
fixture: "SVCategory-Unconcorded-e0fc58d1-8dc5-47c6-90b1-59ccf8217366.json",
conceptIDs: []string{"e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
expectedLen: 2,
expected: expectedConcordanceSVCategory,
},
{
name: "FTAnIIndustryClassification",
fixture: "FTAnIIndustryClassification-97b56e0e-3526-4434-ad29-349b06ead4a3.json",
Expand Down Expand Up @@ -480,6 +562,20 @@ func TestNeoReadByAuthority(t *testing.T) {
identifierValues: []string{"5111"},
expected: expectedConcordanceNAICSIndustryClassificationByAuthority,
},
{
name: "SVProvision",
fixture: "SVProvision-Unconcorded-1808c3fc-04bb-589b-a457-640bffa8f6c6.json",
authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
identifierValues: []string{"65d735ebad5f88460e919a42"},
expected: expectedConcordanceSVProvisionByAuthority,
},
{
name: "SVCategory",
fixture: "SVCategory-Unconcorded-e0fc58d1-8dc5-47c6-90b1-59ccf8217366.json",
authority: "http://api.ft.com/system/8e6c705e-1132-42a2-8db0-c295e29e8658",
identifierValues: []string{"e0fc58d1-8dc5-47c6-90b1-59ccf8217366"},
expected: expectedConcordanceSVCategoryByAuthority,
},
{
name: "FTAnIIndustryClassification",
fixture: "FTAnIIndustryClassification-97b56e0e-3526-4434-ad29-349b06ead4a3.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"aliases": [
"Policy and Regulation"
],
"prefLabel": "Policy and Regulation",
"prefUUID": "e0fc58d1-8dc5-47c6-90b1-59ccf8217366",
"sourceRepresentations": [
{
"authority": "8e6c705e-1132-42a2-8db0-c295e29e8658",
"authorityValue": "e0fc58d1-8dc5-47c6-90b1-59ccf8217366",
"prefLabel": "Policy and Regulation",
"type": "SVCategory",
"uuid": "e0fc58d1-8dc5-47c6-90b1-59ccf8217366"
}
],
"type": "SVCategory"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"aliases": [
"ht"
],
"prefLabel": "ht",
"prefUUID": "1808c3fc-04bb-589b-a457-640bffa8f6c6",
"publishedDate": "2024-02-28T12:00:00.000Z",
"sourceRepresentations": [
{
"authority": "8e6c705e-1132-42a2-8db0-c295e29e8658",
"authorityValue": "65d735ebad5f88460e919a42",
"prefLabel": "ht",
"publishedDate": "2024-02-28T12:00:00.000Z",
"sourceURL": "https://www.fsa.go.jp/news/r4/singi/20221215/02.pdf",
"type": "SVProvision",
"uuid": "1808c3fc-04bb-589b-a457-640bffa8f6c6"
}
],
"sourceURL": "https://www.fsa.go.jp/news/r4/singi/20221215/02.pdf",
"type": "SVProvision"
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.21.2

require (
github.com/Financial-Times/api-endpoint v1.0.0
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.4
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.5
github.com/Financial-Times/cm-neo4j-driver v1.1.1
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7
github.com/Financial-Times/go-logger/v2 v2.0.1
Expand All @@ -24,11 +24,11 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/neo4j/neo4j-go-driver/v4 v4.3.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.13.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/Financial-Times/api-endpoint v1.0.0 h1:EhJfcVcrktPrweue6dCUQAYcEQiXwh+1byIc8a1nypE=
github.com/Financial-Times/api-endpoint v1.0.0/go.mod h1:QrJsxP8uEZIPJZon+qhc+zO7H0634DpoqDI291i0Nag=
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.4 h1:Es3RkoUwbpid8GiLmmw41zVK4sxkAfjqxIKNqHt5hIM=
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.4/go.mod h1:XFireRZKvcX/8piqSQETZSrmT2izcOyyvgqCxCc5ae4=
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.5 h1:KfUnzb4W4nqol1HjSZ95Qc9jUg6l+JmANaypXJkJBqQ=
github.com/Financial-Times/cm-graph-ontology/v2 v2.0.5/go.mod h1:6Y6A7CSTLrH5An3FIP3j3c0ZQrsCDcOI/8SkkJEsOLg=
github.com/Financial-Times/cm-neo4j-driver v1.1.1 h1:kmgRa3boe58+tzNTbWTBx3IQnIZt5Hh57Yc2kHy85FM=
github.com/Financial-Times/cm-neo4j-driver v1.1.1/go.mod h1:fQ77C8A+6I+ihwe6Ob8Y7sIzU3s/DTrjBZJGVQOeum0=
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7 h1:dkf1EOTiHXA2lG2EJuePEim6y0HEOPt0hcqsT/qUr/k=
Expand Down Expand Up @@ -37,8 +37,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA=
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
Expand Down Expand Up @@ -72,8 +72,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rcrowley/go-metrics v0.0.0-20161128210544-1f30fe9094a5/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 h1:uIkTLo0AGRc8l7h5l9r+GcYi9qfVPt6lD4/bhmzfiKo=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
Expand Down