|
| 1 | +/* |
| 2 | +Copyright 2024 Andrew P. Davison, CNRS |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import { defer } from "react-router-dom"; |
| 18 | + |
| 19 | +import { |
| 20 | + buildKGQuery, |
| 21 | + simpleProperty as S, |
| 22 | + linkProperty as L, |
| 23 | + reverseLinkProperty as R, |
| 24 | +} from "../../queries"; |
| 25 | +import { getKGItem } from "../../datastore"; |
| 26 | + |
| 27 | +const query = buildKGQuery("TissueSample", [ |
| 28 | + S("@id"), |
| 29 | + S("lookupLabel"), |
| 30 | + L("anatomicalLocation", [S("name"), S("@type")], { expectSingle: false }), |
| 31 | + L("biologicalSex/name"), |
| 32 | + L("laterality/name"), |
| 33 | + L("origin", [S("name"), S("@type")]), |
| 34 | + L("species", [ |
| 35 | + S("name"), |
| 36 | + S("@type"), |
| 37 | + R("species", "species", [S("name")], { type: "core/Strain" }), |
| 38 | + ]), |
| 39 | + L("strain/name"), |
| 40 | + L("type/name"), |
| 41 | + L( |
| 42 | + "studiedState", |
| 43 | + [ |
| 44 | + S("lookupLabel"), |
| 45 | + L("descendedFrom", [ |
| 46 | + S("lookupLabel"), |
| 47 | + S("@type"), |
| 48 | + R("isStateOf", "studiedState", [S("lookupLabel"), S("@id"), L("type/name")]), |
| 49 | + ]), |
| 50 | + L("age", [ |
| 51 | + S("value"), |
| 52 | + S("uncertainty"), |
| 53 | + S("minValue"), |
| 54 | + S("maxValue"), |
| 55 | + L("unit/name"), |
| 56 | + L("minValueUnit/name"), |
| 57 | + L("maxValueUnit/name"), |
| 58 | + ]), |
| 59 | + L("attribute", [S("name"), S("@type")], { expectSingle: false }), |
| 60 | + S("additionalRemarks"), |
| 61 | + L("pathology", [S("name"), S("@type")], { expectSingle: false }), |
| 62 | + ], |
| 63 | + { expectSingle: false } |
| 64 | + ), |
| 65 | + R( |
| 66 | + "belongsToDataset", |
| 67 | + "studiedSpecimen", |
| 68 | + [ |
| 69 | + S("fullName"), |
| 70 | + S("shortName"), |
| 71 | + S("@id"), |
| 72 | + L("technique/name", [], { filter: "patch clamp", expectSingle: false, required: true }), |
| 73 | + L("accessibility/name", [], { filter: "free access", required: true }), |
| 74 | + R("isVersionOf", "hasVersion", [S("shortName"), S("fullName")]), |
| 75 | + ], |
| 76 | + { required: true } |
| 77 | + ), |
| 78 | +]); |
| 79 | + |
| 80 | +export function getLoader(auth) { |
| 81 | + const loader = async ({ params }) => { |
| 82 | + const stage = auth.isCurator ? ["IN_PROGRESS", "RELEASED"] : "RELEASED"; |
| 83 | + const tissueSamplePromise = getKGItem( |
| 84 | + "patch clamp recordings detail", |
| 85 | + query, |
| 86 | + params.expId, |
| 87 | + auth, |
| 88 | + stage |
| 89 | + ); |
| 90 | + console.log(tissueSamplePromise); |
| 91 | + return defer({ tissueSample: tissueSamplePromise }); |
| 92 | + }; |
| 93 | + return loader; |
| 94 | +} |
0 commit comments