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

EDSC-3909: Fix showing direct collection -> variable associations #1687

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
278 changes: 245 additions & 33 deletions static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,39 +180,39 @@ describe('buildAccessMethods', () => {
'TIFF',
'NETCDF-4'
]
}],
variables: {
count: 4,
items: [{
conceptId: 'V100000-EDSC',
definition: 'Alpha channel value',
longName: 'Alpha channel ',
name: 'alpha_var',
nativeId: 'mmt_variable_3972',
scienceKeywords: null
}, {
conceptId: 'V100001-EDSC',
definition: 'Blue channel value',
longName: 'Blue channel',
name: 'blue_var',
nativeId: 'mmt_variable_3971',
scienceKeywords: null
}, {
conceptId: 'V100002-EDSC',
definition: 'Green channel value',
longName: 'Green channel',
name: 'green_var',
nativeId: 'mmt_variable_3970',
scienceKeywords: null
}, {
conceptId: 'V100003-EDSC',
definition: 'Red channel value',
longName: 'Red Channel',
name: 'red_var',
nativeId: 'mmt_variable_3969',
scienceKeywords: null
}]
}
}]
}]
},
variables: {
count: 4,
items: [{
conceptId: 'V100000-EDSC',
definition: 'Alpha channel value',
longName: 'Alpha channel ',
name: 'alpha_var',
nativeId: 'mmt_variable_3972',
scienceKeywords: null
}, {
conceptId: 'V100001-EDSC',
definition: 'Blue channel value',
longName: 'Blue channel',
name: 'blue_var',
nativeId: 'mmt_variable_3971',
scienceKeywords: null
}, {
conceptId: 'V100002-EDSC',
definition: 'Green channel value',
longName: 'Green channel',
name: 'green_var',
nativeId: 'mmt_variable_3970',
scienceKeywords: null
}, {
conceptId: 'V100003-EDSC',
definition: 'Red channel value',
longName: 'Red Channel',
name: 'red_var',
nativeId: 'mmt_variable_3969',
scienceKeywords: null
}]
}
}
Expand Down Expand Up @@ -523,4 +523,216 @@ describe('buildAccessMethods', () => {
}
})
})

describe('when the collection contains variables associated to its services and variables directly associated to the collection', () => {
test('variables on the collections service are returned instead of directly associated variables', () => {
const collectionMetadata = {
services: {
items: [{
conceptId: 'S100000-EDSC',
longName: 'Mock Service Name',
name: 'mock-name',
type: 'Harmony',
url: {
description: 'Mock URL',
urlValue: 'https://example.com'
},
serviceOptions: {
subset: {
spatialSubset: {
boundingBox: {
allowMultipleValues: false
}
},
variableSubset: {
allowMultipleValues: true
}
},
supportedOutputProjections: [{
projectionName: 'Polar Stereographic'
}, {
projectionName: 'Geographic'
}],
interpolationTypes: [
'Bilinear Interpolation',
'Nearest Neighbor'
],
supportedReformattings: [{
supportedInputFormat: 'NETCDF-4',
supportedOutputFormats: [
'GEOTIFF',
'PNG',
'TIFF',
'NETCDF-4'
]
}, {
supportedInputFormat: 'GEOTIFF',
supportedOutputFormats: [
'GEOTIFF',
'PNG',
'TIFF',
'NETCDF-4'
]
}]
},
supportedOutputProjections: [{
projectionName: 'Polar Stereographic'
}, {
projectionName: 'Geographic'
}],
supportedReformattings: [{
supportedInputFormat: 'NETCDF-4',
supportedOutputFormats: [
'GEOTIFF',
'PNG',
'TIFF',
'NETCDF-4'
]
}, {
supportedInputFormat: 'GEOTIFF',
supportedOutputFormats: [
'GEOTIFF',
'PNG',
'TIFF',
'NETCDF-4'
]
}],
variables: {
count: 4,
items: [{
conceptId: 'V100000-EDSC',
definition: 'Alpha channel value',
longName: 'Alpha channel ',
name: 'alpha_var',
nativeId: 'mmt_variable_3972',
scienceKeywords: null
}, {
conceptId: 'V100001-EDSC',
definition: 'Blue channel value',
longName: 'Blue channel',
name: 'blue_var',
nativeId: 'mmt_variable_3971',
scienceKeywords: null
}, {
conceptId: 'V100002-EDSC',
definition: 'Green channel value',
longName: 'Green channel',
name: 'green_var',
nativeId: 'mmt_variable_3970',
scienceKeywords: null
}, {
conceptId: 'V100003-EDSC',
definition: 'Red channel value',
longName: 'Red Channel',
name: 'red_var',
nativeId: 'mmt_variable_3969',
scienceKeywords: null
}]
}
}]
},
variables: {
count: 3,
items: [{
conceptId: 'V100003-EDSC',
definition: 'Beta channel value',
longName: 'Beta channel ',
name: 'beta_var',
nativeId: 'mmt_variable_4972',
scienceKeywords: null
}, {
conceptId: 'V100004-EDSC',
definition: 'Orange channel value',
longName: 'Orange channel',
name: 'orange_var',
nativeId: 'mmt_variable_4971',
scienceKeywords: null
}, {
conceptId: 'V100005-EDSC',
definition: 'Purple channel value',
longName: 'Purple channel',
name: 'purple_var',
nativeId: 'mmt_variable_4970',
scienceKeywords: null
}]
}
}
const isOpenSearch = false

const methods = buildAccessMethods(collectionMetadata, isOpenSearch)

expect(methods).toEqual({
harmony0: {
enableTemporalSubsetting: true,
enableSpatialSubsetting: true,
hierarchyMappings: [
{
id: 'V100000-EDSC'
},
{
id: 'V100001-EDSC'
},
{
id: 'V100002-EDSC'
},
{
id: 'V100003-EDSC'
}
],
id: 'S100000-EDSC',
isValid: true,
keywordMappings: [],
longName: 'Mock Service Name',
name: 'mock-name',
supportedOutputFormats: [
'GEOTIFF',
'PNG',
'TIFF',
'NETCDF-4'
],
supportedOutputProjections: [],
supportsBoundingBoxSubsetting: true,
supportsShapefileSubsetting: false,
supportsTemporalSubsetting: false,
supportsVariableSubsetting: true,
type: 'Harmony',
url: 'https://example.com',
variables: {
'V100000-EDSC': {
conceptId: 'V100000-EDSC',
definition: 'Alpha channel value',
longName: 'Alpha channel ',
name: 'alpha_var',
nativeId: 'mmt_variable_3972',
scienceKeywords: null
},
'V100001-EDSC': {
conceptId: 'V100001-EDSC',
definition: 'Blue channel value',
longName: 'Blue channel',
name: 'blue_var',
nativeId: 'mmt_variable_3971',
scienceKeywords: null
},
'V100002-EDSC': {
conceptId: 'V100002-EDSC',
definition: 'Green channel value',
longName: 'Green channel',
name: 'green_var',
nativeId: 'mmt_variable_3970',
scienceKeywords: null
},
'V100003-EDSC': {
conceptId: 'V100003-EDSC',
definition: 'Red channel value',
longName: 'Red Channel',
name: 'red_var',
nativeId: 'mmt_variable_3969',
scienceKeywords: null
}
}
}
})
})
})
})
13 changes: 10 additions & 3 deletions static/src/js/util/accessMethods/buildAccessMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import { supportsVariableSubsetting } from './supportsVariableSubsetting'
export const buildAccessMethods = (collectionMetadata, isOpenSearch) => {
const {
granules = {},
services = {}
services = {},
variables: collectionAssociatedVariables = {}
} = collectionMetadata

const accessMethods = {}
let harmonyIndex = 0

let associatedVariables = collectionAssociatedVariables
const { items: serviceItems = null } = services

if (serviceItems !== null) {
Expand All @@ -35,8 +37,13 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => {
maxItemsPerOrder,
name,
supportedReformattings,
variables: associatedVariables
variables: serviceAssociatedVariables = {}
} = serviceItem

if (serviceAssociatedVariables.count > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the service has no variables associated with it, does serviceAssociatedVariables come back as null or { count: 0, items: null }?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first test where you moved the variables to the collection level, it still needs to return something for variables because the graphql query is requesting that field. So updating that test to look correct should answer my question

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes back as { count: 0, items: null } in the graphql response

associatedVariables = serviceAssociatedVariables
}

// Only process service types that EDSC supports
const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony']
if (!supportedServiceTypes.includes(serviceType.toLowerCase())) return
Expand Down
3 changes: 1 addition & 2 deletions static/src/js/util/accessMethods/getVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const computeVariables = (items) => {

/**
* Fetches the variable metadata for the provided variableIds
* @param {Array} variableIds An array of variable Concept Ids
* @param {String} jwtToken JWT returned from edlAuthorizer
* @param {Object} data variable object response from CMR
*/
export const getVariables = (data) => {
const { count } = data
Expand Down