From 7e2e973dee04716501701b412582384973dc1499 Mon Sep 17 00:00:00 2001 From: maxsibilla <maxsibilla@icloud.com> Date: Fri, 25 Oct 2024 08:56:20 -0400 Subject: [PATCH] Updating instances of ingest_metadata.metadata and ingest_metadata.files to be metadata and files --- src/components/custom/entities/Metadata.jsx | 12 ++----- .../custom/entities/dataset/FileTreeView.jsx | 18 +++------- .../custom/vitessce/VignetteList.jsx | 2 +- src/config/search/metadata.js | 36 +++++++++---------- src/context/DerivedContext.jsx | 6 ++-- src/pages/dataset.jsx | 8 ++--- src/pages/publication.jsx | 4 +-- 7 files changed, 35 insertions(+), 51 deletions(-) diff --git a/src/components/custom/entities/Metadata.jsx b/src/components/custom/entities/Metadata.jsx index 7acf5ad7..29cc002b 100644 --- a/src/components/custom/entities/Metadata.jsx +++ b/src/components/custom/entities/Metadata.jsx @@ -123,7 +123,7 @@ function Metadata({data, metadata, mappedMetadata, groups}) { } // The dataset nav link } else if (eq(ancestor.entity_type, cache.entities.dataset)) { - if (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata).length && 'metadata' in ancestor.ingest_metadata) { + if (ancestor.metadata && Object.keys(ancestor.metadata).length > 0) { return ( popoverCommon(index, 'dataset', ancestor) ) @@ -157,18 +157,10 @@ function Metadata({data, metadata, mappedMetadata, groups}) { tabPaneCommon('0', index, ancestor, metadata, undefined, groups) ) } - } else if (!eq(ancestor.entity_type, cache.entities.dataset) && ancestor.metadata && Object.keys(ancestor.metadata).length > 0) { - // Handle mouse source and sample table - // Mice sources and all samples have their metadata inside "metadata" + } else if (ancestor.metadata && Object.keys(ancestor.metadata).length > 0) { return ( tabPaneCommon('1', index, ancestor, ancestor.metadata, ancestor.cedar_mapped_metadata) ) - } else if (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata).length && 'metadata' in ancestor.ingest_metadata) { - // Handle dataset table - // Datasets have their metadata inside "metadata.metadata" - return ( - tabPaneCommon('2', index, ancestor, ancestor.ingest_metadata.metadata, ancestor.cedar_mapped_metadata) - ) } })} </Tab.Content> diff --git a/src/components/custom/entities/dataset/FileTreeView.jsx b/src/components/custom/entities/dataset/FileTreeView.jsx index 01d11aa0..f0a2fb03 100644 --- a/src/components/custom/entities/dataset/FileTreeView.jsx +++ b/src/components/custom/entities/dataset/FileTreeView.jsx @@ -15,7 +15,7 @@ import InputGroup from 'react-bootstrap/InputGroup'; import {Tree} from 'primereact/tree'; import 'primeicons/primeicons.css'; -export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metadata', uuid: 'uuid'}, +export const FileTreeView = ({data, selection = {}, keys = {files: 'files', uuid: 'uuid'}, loadDerived = true, treeViewOnly = false, className = '', filesClassName = '', showQAButton = true, showDataProductButton = true, includeDescription= false, showDownloadAllButton = false}) => { @@ -45,14 +45,6 @@ export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metad return Array.isArray(obj) ? obj.length : Object.keys(obj).length } - const getFiles = (data) => { - if (keys.files.contains('ingest_metadata')) { - return data?.ingest_metadata?.files - } else { - return data[keys.files] - } - } - useEffect( () => { async function fetchData() { await fetchGlobusFilepath(data[keys.uuid]).then((globusData) => { @@ -64,17 +56,17 @@ export const FileTreeView = ({data, selection = {}, keys = {files: 'ingest_metad fetchData() //Default to use files, otherwise wait until derivedDataset is populated - if (getFiles(data) && getLength(getFiles(data))) { + if (data[keys.files] && getLength(data[keys.files])) { setHasData(true) - buildTree(data[keys.uuid], getFiles(data)) + buildTree(data[keys.uuid], data[keys.files]) } }, []) useEffect(() => { if (loadDerived) { - if (isPrimaryDataset && getFiles(derivedDataset) && getLength(getFiles(derivedDataset))) { + if (isPrimaryDataset && derivedDataset[keys.files] && getLength(derivedDataset[keys.files])) { setHasData(true) - buildTree(derivedDataset[keys.uuid], getFiles(derivedDataset)) + buildTree(derivedDataset[keys.uuid], derivedDataset[keys.files]) } } diff --git a/src/components/custom/vitessce/VignetteList.jsx b/src/components/custom/vitessce/VignetteList.jsx index 3317e219..dd4bcd6e 100644 --- a/src/components/custom/vitessce/VignetteList.jsx +++ b/src/components/custom/vitessce/VignetteList.jsx @@ -15,7 +15,7 @@ function VignetteList({ publication, ancillaryPublication }) { const fetchVignettesData = async (uuid) => { log.debug('==== Fetching vignettes data') // ancillaryPublication should have a json config file - const fileName = ancillaryPublication.ingest_metadata.files[0].rel_path + const fileName = ancillaryPublication.files[0].rel_path const path = `${uuid}/${fileName}` const publicationAncillaryConfig = await getJSONFromAssetsEndpoint(path) diff --git a/src/config/search/metadata.js b/src/config/search/metadata.js index 9c81ec9c..afee73bc 100644 --- a/src/config/search/metadata.js +++ b/src/config/search/metadata.js @@ -437,60 +437,60 @@ export const SEARCH_METADATA = { }, // Dataset - 'ingest_metadata.metadata.acquisition_instrument_model': { + 'metadata.acquisition_instrument_model': { label: 'Acquisition Instrument Model', type: 'value', - field: 'ingest_metadata.metadata.acquisition_instrument_model.keyword', + field: 'metadata.acquisition_instrument_model.keyword', isExpanded: false, filterType: 'any', isFilterable: false, facetType: 'term', isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']), - isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.acquisition_instrument_model') + isFacetVisible: doesAggregationHaveBuckets('metadata.acquisition_instrument_model') }, - 'ingest_metadata.metadata.acquisition_instrument_vendor': { + 'metadata.acquisition_instrument_vendor': { label: 'Acquisition Instrument Vendor', type: 'value', - field: 'ingest_metadata.metadata.acquisition_instrument_vendor.keyword', + field: 'metadata.acquisition_instrument_vendor.keyword', isExpanded: false, filterType: 'any', isFilterable: false, facetType: 'term', isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']), - isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.acquisition_instrument_vendor') + isFacetVisible: doesAggregationHaveBuckets('metadata.acquisition_instrument_vendor') }, - 'ingest_metadata.metadata.analyte_class': { + 'metadata.analyte_class': { label: 'Analyte Class', type: 'value', - field: 'ingest_metadata.metadata.analyte_class.keyword', + field: 'metadata.analyte_class.keyword', isExpanded: false, filterType: 'any', isFilterable: false, facetType: 'term', isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']), - isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.analyte_class') + isFacetVisible: doesAggregationHaveBuckets('metadata.analyte_class') }, - 'ingest_metadata.metadata.assay_category': { + 'metadata.assay_category': { label: 'Assay Category', type: 'value', - field: 'ingest_metadata.metadata.assay_category.keyword', + field: 'metadata.assay_category.keyword', isExpanded: false, filterType: 'any', isFilterable: false, facetType: 'term', isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']), - isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.assay_category') + isFacetVisible: doesAggregationHaveBuckets('metadata.assay_category') }, - 'ingest_metadata.metadata.operator': { + 'metadata.operator': { label: 'Operator', type: 'value', - field: 'ingest_metadata.metadata.operator.keyword', + field: 'metadata.operator.keyword', isExpanded: false, filterType: 'any', isFilterable: false, facetType: 'term', isAggregationActive: doesTermFilterContainValues('entity_type', ['Dataset']), - isFacetVisible: doesAggregationHaveBuckets('ingest_metadata.metadata.operator') + isFacetVisible: doesAggregationHaveBuckets('metadata.operator') }, }, disjunctiveFacets: [], @@ -599,7 +599,7 @@ export const SEARCH_METADATA = { entityType: 'dataset', queryString: searchUIQueryString([ {field: 'entity_type', values: ['Dataset'], type: 'any'}, - {field: 'ingest_metadata.metadata.analyte_class', values: ['Nucleic acid and protein'], type: 'any'} + {field: 'metadata.analyte_class', values: ['Nucleic acid and protein'], type: 'any'} ]) }, { @@ -608,7 +608,7 @@ export const SEARCH_METADATA = { entityType: 'dataset', queryString: searchUIQueryString([ {field: 'entity_type', values: ['Dataset'], type: 'any'}, - {field: 'ingest_metadata.metadata.analyte_class', values: ['RNA'], type: 'any'} + {field: 'metadata.analyte_class', values: ['RNA'], type: 'any'} ]) }, { @@ -617,7 +617,7 @@ export const SEARCH_METADATA = { entityType: 'dataset', queryString: searchUIQueryString([ {field: 'entity_type', values: ['Dataset'], type: 'any'}, - {field: 'ingest_metadata.metadata.assay_category', values: ['sequence'], type: 'any'} + {field: 'metadata.assay_category', values: ['sequence'], type: 'any'} ]) }, ], diff --git a/src/context/DerivedContext.jsx b/src/context/DerivedContext.jsx index 8fdd9a9c..b781ae30 100644 --- a/src/context/DerivedContext.jsx +++ b/src/context/DerivedContext.jsx @@ -149,15 +149,15 @@ export const DerivedProvider = ({children, showVitessceList, setShowVitessceList if (datasetIs.processed(entity.creation_action)) { const response = await fetch("/api/find?uuid=" + entity.uuid, getRequestHeaders()) const processed = await response.json() - if (processed.ingest_metadata && processed.ingest_metadata.files && processed.ingest_metadata.files.length) { - let dataProducts = filterFilesForDataProducts(processed.ingest_metadata.files, processed) + if (processed.files && processed.files.length) { + let dataProducts = filterFilesForDataProducts(processed.files, processed) _files = _files.concat(dataProducts) } } } setDataProducts(_files) } else { - _files = data.ingest_metadata?.files || [] + _files = data?.files || [] setDataProducts(filterFilesForDataProducts(_files, data)) } diff --git a/src/pages/dataset.jsx b/src/pages/dataset.jsx index f973ed7a..abaf6fb1 100644 --- a/src/pages/dataset.jsx +++ b/src/pages/dataset.jsx @@ -108,7 +108,7 @@ function ViewDataset() { for (const ancestor of ancestry.ancestors) { console.log(ancestor) - if ((ancestor.metadata && Object.keys(ancestor.metadata).length) || (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata) && 'metadata' in ancestor.ingest_metadata)) { + if ((ancestor.metadata && Object.keys(ancestor.metadata).length)) { setAncestorHasMetadata(true) break } @@ -194,7 +194,7 @@ function ViewDataset() { data-bs-parent="#sidebar">Provenance</a> </li> - {!!((data.ingest_metadata && Object.keys(data.ingest_metadata).length && 'metadata' in data.ingest_metadata) || ancestorHasMetadata) && + {!!((data.metadata && Object.keys(data.metadata).length || ancestorHasMetadata)) && <li className="nav-item"> <a href="#Metadata" className="nav-link" @@ -264,10 +264,10 @@ function ViewDataset() { {/*Metadata*/} {/*Datasets have their metadata inside "metadata.metadata"*/} - {!!((data.ingest_metadata && Object.keys(data.ingest_metadata).length && 'metadata' in data.ingest_metadata) || ancestorHasMetadata) && + {!!((data.metadata && Object.keys(data.metadata).length) || ancestorHasMetadata) && <Metadata data={data} - metadata={data?.ingest_metadata?.metadata} + metadata={data?.metadata} mappedMetadata={data?.cedar_mapped_metadata} /> } diff --git a/src/pages/publication.jsx b/src/pages/publication.jsx index 1a16c915..edd774ee 100644 --- a/src/pages/publication.jsx +++ b/src/pages/publication.jsx @@ -57,10 +57,10 @@ function ViewPublication() { // get the most recent ancillary publication ancillaryPublication = _data.descendants .sort((a, b) => new Date(b.last_modified_timestamp) - new Date(a.last_modified_timestamp)) - .find(d => d.dataset_type === 'Publication [ancillary]' && d.ingest_metadata?.files[0]?.rel_path) + .find(d => d.dataset_type === 'Publication [ancillary]' && d?.files[0]?.rel_path) } else { ancillaryPublication = _data.descendants - .find(d => d.dataset_type === 'Publication [ancillary]' && d.ingest_metadata?.files[0]?.rel_path) + .find(d => d.dataset_type === 'Publication [ancillary]' && d?.files[0]?.rel_path) } setAncillaryPublicationData(ancillaryPublication || {})