Skip to content

Commit

Permalink
Merge pull request #1105 from sennetconsortium/libpitt/1090-dataset_type
Browse files Browse the repository at this point in the history
Libpitt/1090 dataset type
  • Loading branch information
maxsibilla authored Dec 14, 2023
2 parents daf4027 + 6f7bcdb commit 5ada11d
Show file tree
Hide file tree
Showing 25 changed files with 147 additions and 229 deletions.
4 changes: 2 additions & 2 deletions src/components/custom/TableResultsEntities.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ function TableResultsEntities({children, filters, onRowClicked, forData = false,

const datasetColumns = [
{
name: 'Data Types',
name: 'Dataset Type',
selector: row => {
let val = raw(row.data_types)
let val = raw(row.dataset_type)
if (val) {
return Array.isArray(val) ? getUBKGFullName(val[0]) : val
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/custom/TableResultsFiles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function TableResultsFiles({children, filters, forData = false, rowFn, inModal =
for (let file of rawResponse.records.files) {
if (!results.hasOwnProperty(file.dataset_uuid)) {
results[file.dataset_uuid] = {
data_types: file.data_types,
dataset_type: file.dataset_type,
dataset_sennet_id: file.dataset_sennet_id,
dataset_uuid: file.dataset_uuid,
donors: file.donors,
Expand Down Expand Up @@ -243,9 +243,9 @@ function TableResultsFiles({children, filters, forData = false, rowFn, inModal =

cols.push(
{
name: 'Data Types',
name: 'Dataset Type',
selector: row => {
let val = raw(row.data_types)
let val = raw(row.dataset_types)
if (val) {
return Array.isArray(val) ? getUBKGFullName(val[0]) : val
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/bulk/BulkCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export default function BulkCreate({
typeCol = 'sample_category'
labIdCol = 'lab_tissue_sample_id'
} else {
typeCol = 'data_types'
typeCol = 'dataset_type'
labIdCol = 'lab_dataset_id'
}
return {typeCol, labIdCol}
Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/edit/dataset/AncestorIds.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function AncestorIds({values, onChange, fetchAncestors, deleteAnc
// const excludeDataTypes = getDataTypesByProperty("vis-only", true)
const excludeNonPrimaryTypes = getDataTypesByProperty("primary", false)
valid_dataset_ancestor_config['searchQuery']['excludeFilters'].push({
keyword: "data_types.keyword",
keyword: "dataset_type.keyword",
value: excludeNonPrimaryTypes
});
}, [])
Expand Down
112 changes: 0 additions & 112 deletions src/components/custom/edit/dataset/DataTypes.jsx

This file was deleted.

49 changes: 49 additions & 0 deletions src/components/custom/edit/dataset/DatasetType.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import {Col, Form, Row} from 'react-bootstrap';
import {QuestionCircleFill} from "react-bootstrap-icons";
import SenNetPopover from "../../../SenNetPopover";
import {getUBKGFullName} from "../../js/functions";

export default function DatasetType({datasetTypes, data, onChange}) {

return (
//Data Types
<>
<Form.Group className="mb-3" controlId="dataset_type">
<Form.Label>Dataset Type <span
className="required">* </span>
<SenNetPopover className={'dataset_type'}
text={<>The type of data contained in this <code>Dataset</code>. Choose from one
of the available options.</>}>
<QuestionCircleFill/>
</SenNetPopover>
</Form.Label>

{/*Check that there exists a data type for this dataset and if it is not a part of the list of primary assay types*/}
{data?.dataset_type && !datasetTypes.includes(data.dataset_type) ?
(
<Form.Select required aria-label="Dataset Type" disabled>
<option
value={data.dataset_type}>{getUBKGFullName(data.dataset_type)}</option>
</Form.Select>
) : (
<Form.Select required aria-label="Dataset Type"
onChange={(e) => onChange(e, 'dataset_type', e.target.value)}
name={'dataset_type'}
defaultValue={data?.dataset_type}>
<option value="">----</option>
{datasetTypes.map(data_type => {
return (
<option key={data_type} value={data_type.trim()}>
{getUBKGFullName(data_type)}
</option>
);
})}
</Form.Select>
)}

</Form.Group>
</>
)

}
3 changes: 1 addition & 2 deletions src/components/custom/entities/sample/DerivedDatasetItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default class DerivedDatasetItem extends React.Component {
return (
<>
<td>
{Array.isArray(this.state.descendant_data.data_types) ?
this.state.descendant_data.data_types.join(', ') : this.state.descendant_data.data_types}
{this.state.descendant_data.dataset_type}
</td>
<td>
<span className={`${getStatusColor(this.state.descendant_data.status)} badge`}>
Expand Down
25 changes: 4 additions & 21 deletions src/components/custom/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ export function getDataTypesByProperty(property, value) {
return window.UBKG_CACHE.dataTypesObj.filter(data_type => data_type[property] === value).map(data_type => data_type.data_type);
}

export function getIsPrimaryDataset(data) {
return equals(data.dataset_category, 'primary') || equals(data.creation_action, 'Create Dataset Activity')
}

export function getDOIPattern() {
return "(^(http(s)?:\/\/)?dx.doi.org\/10.\\d{4,9}\/protocols\.io\..+)|(^(http(s)?:\/\/)?doi.org\/10.\\d{4,9}\/protocols\.io\..+)"
}
Expand Down Expand Up @@ -308,27 +312,6 @@ export function checkMultipleFilterType(filters, field = 'entity_type') {
return hasMultipleType;
}

export function isPrimaryAssay(data, verifyAll = false) {
let dict = {}
let result = false
for (let assay of window.UBKG_CACHE.dataTypesObj) {
dict[assay.data_type] = assay.primary
}
for (let assay of data.data_types) {
if (dict[assay]) {
result = true
if (!verifyAll) {
return true
}
} else {
if (verifyAll) {
return false
}
}
}
return result;
}

export function cleanJson(json) {
Object.entries(json).forEach(([key, val]) =>
(val && typeof val === 'object') && cleanJson(val) ||
Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/layout/entity/VersionsDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function VersionsDropdown({data}) {
const buildOptions = (r) => {
let results = []
for (let s of r.uuids) {
results.push({value: s.uuid, label: `${s.sennet_id} (${s.data_types[0]})`, revision: r})
results.push({value: s.uuid, label: `${s.sennet_id} (${s.dataset_type})`, revision: r})
}
return results
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/layout/entity/ViewHeaderBadges.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function ViewHeaderBadges({data, uniqueHeader, uniqueHeaderUrl, isMetadataHeader
) : (
<h5 className={"title_badge"}>
<span className="badge bg-secondary ms-2">
{getUBKGFullName(data.data_types[0])}
{getUBKGFullName(data.dataset_type)}
</span>
</h5>
)
Expand Down
27 changes: 17 additions & 10 deletions src/config/search/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ const connector = new SearchAPIConnector({
export const SEARCH_ENTITIES = {
alwaysSearchOnInitialLoad: true,
searchQuery: {
excludeFilters: [ {
keyword: "entity_type.keyword",
value: "Publication"
}
excludeFilters: [
{
keyword: "entity_type.keyword",
value: "Publication"
},
{
keyword: "dataset_category.keyword",
value: ["codcc-processed", "lab-processed"]
}
],
facets: {
entity_type: {
Expand Down Expand Up @@ -67,16 +72,16 @@ export const SEARCH_ENTITIES = {
filterType: 'any',
isFilterable: false,
},
data_types: {
label: 'Data Type',
dataset_type: {
label: 'Dataset Type',
type: 'value',
field: 'data_types.keyword',
field: 'dataset_type.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
},
has_rui_information: {
label: 'Has Location Information',
label: 'Is Spatially Registered',
type: 'value',
field: 'has_rui_information.keyword',
isExpanded: false,
Expand Down Expand Up @@ -156,7 +161,8 @@ export const SEARCH_ENTITIES = {
lab_name: {type: 'value'},
lab_tissue_sample_id: {type: 'value'},
source_type: {type: 'value'},
data_types: {type: 'value'},
dataset_type: {type: 'value'},
dataset_category: {type: 'value'},
sample_category: {type: 'value'},
lab_dataset_id: {type: 'value'},
created_by_user_displayname: {type: 'value'},
Expand All @@ -182,7 +188,8 @@ export const SEARCH_ENTITIES = {
'source_type',
'source.source_type',
'last_modified_timestamp',
'data_types',
'dataset_type',
'dataset_category',
'status',
'origin_sample.organ',
'organ',
Expand Down
10 changes: 5 additions & 5 deletions src/config/search/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const sourceItems = [
'sennet_id',
'dataset_sennet_id',
'checksum',
'data_types',
'dataset_type',
'description',
'dataset_uuid',
'donors',
Expand Down Expand Up @@ -45,10 +45,10 @@ export const SEARCH_FILES = {
filterType: 'any',
isFilterable: false,
},
data_types: {
label: 'Data Type',
dataset_type: {
label: 'Dataset Type',
type: 'value',
field: 'data_types.keyword',
field: 'dataset_type.keyword',
isExpanded: false,
filterType: 'any',
isFilterable: false,
Expand All @@ -72,7 +72,7 @@ export const SEARCH_FILES = {
'organs.type': {type: 'value'},
'samples.type': {type: 'value'},
dataset_sennet_id: {type: 'value'},
data_types: {type: 'value'}
dataset_type: {type: 'value'}
},
source_fields: sourceItems,
},
Expand Down
Loading

0 comments on commit 5ada11d

Please sign in to comment.