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

Add support for FTAnIIndustryClassifications #52

Merged
merged 2 commits into from
Nov 24, 2022
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
23 changes: 22 additions & 1 deletion concordances/cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type CypherDriver struct {
env string
}

//NewCypherDriver instantiate driver
// NewCypherDriver instantiate driver
func NewCypherDriver(driver *cmneo4j.Driver, env string) CypherDriver {
return CypherDriver{driver, env}
}
Expand Down Expand Up @@ -63,6 +63,13 @@ func (cd CypherDriver) ReadByConceptID(identifiers []string) (concordances Conco
RETURN DISTINCT canonical.prefUUID AS canonicalUUID, labels(canonical) AS types, 'NAICS' as authority, canonical.industryIdentifier as authorityValue
UNION ALL

MATCH (p:FTAnIIndustryClassification)
WHERE p.uuid in $identifiers
MATCH (p)-[:EQUIVALENT_TO]->(canonical:Concept)
WHERE exists(canonical.industryIdentifier)
RETURN DISTINCT canonical.prefUUID AS canonicalUUID, labels(canonical) AS types, 'FTAnI' as authority, canonical.industryIdentifier as authorityValue
UNION ALL

MATCH (p:Thing)
WHERE p.uuid in $identifiers
MATCH (p)-[:EQUIVALENT_TO]->(canonical:Concept)
Expand Down Expand Up @@ -154,6 +161,19 @@ func (cd CypherDriver) ReadByAuthority(authority string, identifierValues []stri
},
Result: &results,
}
} else if authorityProperty == "FTAnI" {
query = &cmneo4j.Query{
Cypher: `
MATCH (canonical:FTAnIIndustryClassification)
WHERE canonical.industryIdentifier IN $authorityValue
AND exists(canonical.prefUUID)
RETURN DISTINCT canonical.prefUUID AS canonicalUUID, labels(canonical) AS types, canonical.uuid as UUID, 'FTAnI' as authority, canonical.industryIdentifier as authorityValue
`,
Params: map[string]interface{}{
"authorityValue": identifierValues,
},
Result: &results,
}
} else {
query = &cmneo4j.Query{
Cypher: `
Expand Down Expand Up @@ -235,6 +255,7 @@ var authorityMap = map[string]string{
"Wikidata": "http://api.ft.com/system/WIKIDATA",
"DBPedia": "http://api.ft.com/system/DBPEDIA",
"NAICS": "http://api.ft.com/system/NAICS",
"FTAnI": "http://api.ft.com/system/FT-AnI",
}

func AuthorityFromURI(uri string) (string, bool) {
Expand Down
52 changes: 52 additions & 0 deletions concordances/cypher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,40 @@ func TestNeoReadByConceptID(t *testing.T) {
expectedLen: 3,
expected: expectedConcordanceNAICSIndustryClassification,
},
{
name: "FTAnIIndustryClassification",
fixture: "FTAnIIndustryClassification-97b56e0e-3526-4434-ad29-349b06ead4a3.json",
conceptIDs: []string{"97b56e0e-3526-4434-ad29-349b06ead4a3"},
expectedLen: 3,
expected: Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3",
APIURL: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3"},
Identifier{
Authority: "http://api.ft.com/system/SMARTLOGIC",
IdentifierValue: "97b56e0e-3526-4434-ad29-349b06ead4a3"},
},
{
Concept{
ID: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3",
APIURL: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3"},
Identifier{
Authority: "http://api.ft.com/system/FT-AnI",
IdentifierValue: "ELE"},
},
{
Concept{
ID: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3",
APIURL: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3"},
Identifier{
Authority: "http://api.ft.com/system/UPP",
IdentifierValue: "97b56e0e-3526-4434-ad29-349b06ead4a3"},
},
},
},
},
}

for _, test := range tests {
Expand Down Expand Up @@ -453,6 +487,24 @@ func TestNeoReadByAuthority(t *testing.T) {
identifierValues: []string{"5111"},
expected: expectedConcordanceNAICSIndustryClassificationByAuthority,
},
{
name: "FTAnIIndustryClassification",
fixture: "FTAnIIndustryClassification-97b56e0e-3526-4434-ad29-349b06ead4a3.json",
authority: "http://api.ft.com/system/FT-AnI",
identifierValues: []string{"ELE"},
expected: Concordances{
[]Concordance{
{
Concept{
ID: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3",
APIURL: "http://api.ft.com/things/97b56e0e-3526-4434-ad29-349b06ead4a3"},
Identifier{
Authority: "http://api.ft.com/system/FT-AnI",
IdentifierValue: "ELE"},
},
},
},
},
{
name: "EmptyConcordancesWhenUnsupportedAuthority",
fixture: "Organisation-BankOfTest-cd7e4345-f11f-41f3-a0f0-2cf5c43e0115.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"prefUUID": "97b56e0e-3526-4434-ad29-349b06ead4a3",
"type": "FTAnIIndustryClassification",
"prefLabel": "Electrical/Electronic Manufacturing",
"aliases": [
"Electrical/Electronic Manufacturing"
],
"industryIdentifier": "ELE",
"sourceRepresentations": [
{
"uuid": "97b56e0e-3526-4434-ad29-349b06ead4a3",
"type": "FTAnIIndustryClassification",
"prefLabel": "Electrical/Electronic Manufacturing",
"aliases": [
"Electrical/Electronic Manufacturing"
],
"authority": "Smartlogic",
"authorityValue": "97b56e0e-3526-4434-ad29-349b06ead4a3",
"industryIdentifier": "ELE"
}
]
}
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.17

require (
github.com/Financial-Times/api-endpoint v1.0.0
github.com/Financial-Times/cm-neo4j-driver v1.1.0
github.com/Financial-Times/concepts-rw-neo4j v1.34.0
github.com/Financial-Times/cm-neo4j-driver v1.1.1
github.com/Financial-Times/concepts-rw-neo4j v1.35.6
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7
github.com/Financial-Times/go-logger/v2 v2.0.1
github.com/Financial-Times/http-handlers-go/v2 v2.3.0
github.com/Financial-Times/neo-model-utils-go v1.0.0
github.com/Financial-Times/neo-model-utils-go v1.1.1
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d
github.com/Financial-Times/transactionid-utils-go v0.2.0
github.com/gorilla/handlers v1.4.0
Expand All @@ -22,9 +22,10 @@ require (
)

require (
github.com/Financial-Times/cm-graph-ontology v0.0.1 // indirect
github.com/Financial-Times/cm-graph-ontology v1.1.1 // indirect
github.com/Financial-Times/up-rw-app-api-go v0.0.0-20170710125828-d9d93a1f6895 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/mitchellh/hashstructure v1.0.0 // indirect
github.com/neo4j/neo4j-go-driver/v4 v4.3.3 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ github.com/Financial-Times/api-endpoint v1.0.0 h1:EhJfcVcrktPrweue6dCUQAYcEQiXwh
github.com/Financial-Times/api-endpoint v1.0.0/go.mod h1:QrJsxP8uEZIPJZon+qhc+zO7H0634DpoqDI291i0Nag=
github.com/Financial-Times/cm-graph-ontology v0.0.1 h1:11J8a0+QOe1SfbCnDvLQT2R75qUz4XmGQuOGQbDJt4A=
github.com/Financial-Times/cm-graph-ontology v0.0.1/go.mod h1:h/8ojXW//7avrChq3Tk+TcHpNmBhL59YQMvS8T0tvd4=
github.com/Financial-Times/cm-graph-ontology v1.1.1 h1:U5QAFzeuV/DQD5CN+EHrBaD1Nvu2fjRzav0/9kgWnpY=
github.com/Financial-Times/cm-graph-ontology v1.1.1/go.mod h1:Bku34350G+ZZh31w5lDAXlzLJH4Sc5ZmWyiQdp9PlHo=
github.com/Financial-Times/cm-neo4j-driver v1.1.0 h1:9TZgyE7Vl8iuH0MRQlrVLkjzLFwIQsCn/td806WU7A8=
github.com/Financial-Times/cm-neo4j-driver v1.1.0/go.mod h1:fQ77C8A+6I+ihwe6Ob8Y7sIzU3s/DTrjBZJGVQOeum0=
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/concepts-rw-neo4j v0.0.0-20221122104052-06a3554173f4 h1:Y57ROG4a8zUFTHsykVJq7lQRgkbeWmpefPuJ86N1N2U=
github.com/Financial-Times/concepts-rw-neo4j v0.0.0-20221122104052-06a3554173f4/go.mod h1:QUbERXUYVCcVlc1SSXVAeMJ7WYY4b4mjzBIWFCmxxYs=
github.com/Financial-Times/concepts-rw-neo4j v1.34.0 h1:v+hibGNaK+O5MAafQCvtvB9ebuDaf7wEMNCFqC67n5w=
github.com/Financial-Times/concepts-rw-neo4j v1.34.0/go.mod h1:5m1WkNN285ydOBqXyl3QzZXs/lOvjqYAyW7bY0Xk/aI=
github.com/Financial-Times/concepts-rw-neo4j v1.35.6 h1:To7jnWcOj+66cBClbVBWI2d84VksLi4Si9uxcoExwfk=
github.com/Financial-Times/concepts-rw-neo4j v1.35.6/go.mod h1:QUbERXUYVCcVlc1SSXVAeMJ7WYY4b4mjzBIWFCmxxYs=
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7 h1:dkf1EOTiHXA2lG2EJuePEim6y0HEOPt0hcqsT/qUr/k=
github.com/Financial-Times/go-fthealth v0.0.0-20171204124831-1b007e2b37b7/go.mod h1:gpAzq6W5rCheYlY32JOIxS/VjVcYHbC2PkMzQngHT9c=
github.com/Financial-Times/go-logger/v2 v2.0.1 h1:iekEfSsUtlkg+YkXTZo+/fIN2VbZ2/3Hl9yolP3z5X8=
Expand All @@ -14,6 +22,8 @@ github.com/Financial-Times/http-handlers-go/v2 v2.3.0 h1:/DqRBffuPpnKsFC+DcXSdXl
github.com/Financial-Times/http-handlers-go/v2 v2.3.0/go.mod h1:Tgkc7TqJXl/NFxB8eP8CX7YU5X01gbrL55LqNzo4YVY=
github.com/Financial-Times/neo-model-utils-go v1.0.0 h1:0iTxDtXKkJ9vYQDE73KM/+ghtFLdq0U6bQPdiwaSEaQ=
github.com/Financial-Times/neo-model-utils-go v1.0.0/go.mod h1:D5ny/A+002uCPCZbtP/E+qpY3//gYJzHw6sqqBUm2Lc=
github.com/Financial-Times/neo-model-utils-go v1.1.1 h1:couVMV7KahWcGl7cUxMYhOD9wX+J8ld7Tcrp3VvB5d0=
github.com/Financial-Times/neo-model-utils-go v1.1.1/go.mod h1:D5ny/A+002uCPCZbtP/E+qpY3//gYJzHw6sqqBUm2Lc=
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d h1:USNBTIof6vWGM49SYrxvC5Y8NqyDL3YuuYmID81ORZQ=
github.com/Financial-Times/service-status-go v0.0.0-20160323111542-3f5199736a3d/go.mod h1:7zULC9rrq6KxFkpB3Y5zNVaEwrf1g2m3dvXJBPDXyvM=
github.com/Financial-Times/transactionid-utils-go v0.2.0 h1:YcET5Hd1fUGWWpQSVszYUlAc15ca8tmjRetUuQKRqEQ=
Expand Down Expand Up @@ -44,6 +54,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
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/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
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=
Expand Down