Skip to content
Snippets Groups Projects
Commit d2bfc676 authored by Isa H's avatar Isa H
Browse files

pharmaStructure from form

parent b749cc94
No related branches found
No related tags found
1 merge request!2Dev2
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</v-toolbar> </v-toolbar>
<v-card-text> <v-card-text>
<v-layout row> <v-layout row>
<ph-d-jsonld :jsonld="displayjsonld" :pid="pid"></ph-d-jsonld> <ph-d-jsonld :form="form" :jsonld="displayjsonld" :pid="pid"></ph-d-jsonld>
</v-layout> </v-layout>
</v-card-text> </v-card-text>
</v-card> </v-card>
...@@ -267,8 +267,8 @@ export default { ...@@ -267,8 +267,8 @@ export default {
}, },
members: [], members: [],
pid: "o:584804", pid: "o:585934",
//"o:584804",
piddoc: {}, piddoc: {},
collection: "", collection: "",
sampleCollection: "", sampleCollection: "",
......
...@@ -289,6 +289,7 @@ ...@@ -289,6 +289,7 @@
</template> </template>
<template v-else-if="p==='dcterms:subject'" slot="dcterms:subject"> <template v-else-if="p==='dcterms:subject'" slot="dcterms:subject">
<v-btn @click="pharmaStructure()">form</v-btn>
<template v-for="(subject, j) in o"> <template v-for="(subject, j) in o">
<v-card <v-card
class="mt-3" class="mt-3"
...@@ -320,7 +321,7 @@ ...@@ -320,7 +321,7 @@
<template v-if="sec.selections"> <template v-if="sec.selections">
<v-card v-for="s in sec.selections" :key="s.label+'t'"> <v-card v-for="s in sec.selections" :key="s.label+'t'">
s {{s}} {{sec.type}} {{s.label}} if{{getSelectionElem(sec.type,s.label)}} s {{s}} type {{sec.type}} label {{s.label}} if {{getSelectionElem(sec.type,s.label)}}
<v-layout v-if="getSelectionElem(sec.type,s.label).length>0"> <v-layout v-if="getSelectionElem(sec.type,s.label).length>0">
<v-flex xs1 class="subheading"> <v-flex xs1 class="subheading">
<a :href="s.id" target="_blank">{{s.label}}</a> <a :href="s.id" target="_blank">{{s.label}}</a>
...@@ -426,20 +427,63 @@ export default { ...@@ -426,20 +427,63 @@ export default {
instance: function() { instance: function() {
return this.$store.state.settings.instance; return this.$store.state.settings.instance;
}, },
s: function() {
return this.form.sections;
},
componentid: function() { componentid: function() {
return Math.floor(Math.random() * 10000000); return Math.floor(Math.random() * 10000000);
}, },
pharmaStructure: function() {
var subjectjson = this.jsonld["dcterms:subject"];
//filter subjects for only the ones with subjects[i]["@type"]=!= "skos:Concept"
//that would be the pharma-related subjects
var pharmajson = subjectjson.filter(
subjectjson => subjectjson["@type"] != "skos:Concept"
);
console.log("phamra json", pharmajson);
console.log("formCategories", this.s[2].categories);
var formCategories = this.s[2].categories;
var jsonStructured = [];
for (let i = 0; i < formCategories.length; i++) {
//only look at the ones which have not a skos:Concept type
var formFields = formCategories[i].fields;
jsonStructured.push({ category: formCategories[i].description });
var formFieldsFiltered = formFields.filter(
formFields => formFields.type != "skos:Concept"
);
//check which of those filetered fields ffields have a value in subjects
console.log("jsonStructured", jsonStructured, formFieldsFiltered);
for (var j = 0; j < formFieldsFiltered.length; j++) {
// console.log("ffields[j].type", ffields[j].type);
//filter all the elem in subjects which have this type
var jsonTypeArray = pharmajson.filter(function(fs) {
return fs["@type"] == formFieldsFiltered[j].type;
});
if (jsonTypeArray.length > 0) {
console.log(
"got those",
jsonTypeArray,
"for",
formFieldsFiltered[j].type
);
}
}
}
},
pharmaData: function() { pharmaData: function() {
var s = this.jsonld["dcterms:subject"]; var s = this.jsonld["dcterms:subject"];
//filter subjects for only the ones with subjects[i]["@type"]=!= "skos:Concept" //filter subjects for only the ones with subjects[i]["@type"]=!= "skos:Concept"
//that would be the pharma-related subjects //that would be the pharma-related subjects
var subjects = s.filter(s => s["@type"] != "skos:Concept"); var subjects = s.filter(s => s["@type"] != "skos:Concept");
console.log("subject1", subjects);
var n_subjects = []; var n_subjects = [];
// take all the jsonld["dcterms:subject"] but not the ones which have no skos:prefLabel" // take all the jsonld["dcterms:subject"] but not the ones which have no skos:prefLabel"
for (let i = 0; i < subjects.length; i++) { for (let i = 0; i < subjects.length; i++) {
console.log("subject", subjects[i]);
var subcat = subjects[i]["@type"]; // thuis should be unique to each entry field, comes from "subjectType" in jsonld var subcat = subjects[i]["@type"]; // thuis should be unique to each entry field, comes from "subjectType" in jsonld
var categ = this.getCategory(subcat); var categ = this.getCategory(subcat);
...@@ -457,6 +501,7 @@ export default { ...@@ -457,6 +501,7 @@ export default {
n_subjects[i].data = subjects[i]; n_subjects[i].data = subjects[i];
} }
console.log("pharmaData", n_subjects); console.log("pharmaData", n_subjects);
console.log("pharmaSubjects", this.pharmaSubjects);
return n_subjects; return n_subjects;
} }
}, },
...@@ -469,7 +514,11 @@ export default { ...@@ -469,7 +514,11 @@ export default {
type: Object, type: Object,
default: null default: null
}, },
pid: String pid: String,
form: {
type: Object,
default: null
}
}, },
components: { components: {
PDTitle, PDTitle,
...@@ -496,7 +545,7 @@ export default { ...@@ -496,7 +545,7 @@ export default {
}, },
data() { data() {
return { return {
pharmaSubjects: [ /*pharmaSubjects: [
{ {
type: "biologicalMacromolecule", type: "biologicalMacromolecule",
voc: "biological_macromolecule", voc: "biological_macromolecule",
...@@ -548,7 +597,7 @@ export default { ...@@ -548,7 +597,7 @@ export default {
title: "Involved discipline", title: "Involved discipline",
id: this.getinfoRef("discipline") id: this.getinfoRef("discipline")
} }
] ]*/
}; };
}, },
methods: { methods: {
...@@ -563,7 +612,7 @@ export default { ...@@ -563,7 +612,7 @@ export default {
return elem; return elem;
}, },
getSelectionElem: function(categ, selection) { getSelectionElem: function(categ, selection) {
console.log("categ", categ, selection); console.log("categ", categ, "selec", selection);
var elem = this.pharmaData.filter( var elem = this.pharmaData.filter(
pharmaData => pharmaData =>
pharmaData.category === categ && pharmaData.selection === selection pharmaData.category === categ && pharmaData.selection === selection
......
...@@ -217,6 +217,11 @@ export default { ...@@ -217,6 +217,11 @@ export default {
}) })
.then(function(body) { .then(function(body) {
self.data = body; self.data = body;
//if body is empty, then just use whatever was there already in the data getData
if (body.result == "empty") {
self.data = self.getData;
}
}) })
.catch(function(error) { .catch(function(error) {
......
...@@ -1236,7 +1236,7 @@ const fields = [ ...@@ -1236,7 +1236,7 @@ const fields = [
ontology: "bao", ontology: "bao",
ontClass: "BAO_0000029", ontClass: "BAO_0000029",
topId: "BAO_0000029", topId: "BAO_0000029",
//category: ["assay"], category: ["assay"],
// baseurl: "http://www.bioassayontology.org/bao#", // baseurl: "http://www.bioassayontology.org/bao#",
description: "Assay screening campaign stage:", description: "Assay screening campaign stage:",
info: info:
...@@ -1246,10 +1246,10 @@ const fields = [ ...@@ -1246,10 +1246,10 @@ const fields = [
{ {
id: "0-Organism", id: "0-Organism",
predicate: "dcterms:subject", predicate: "dcterms:subject",
type: "pharmaWien:assayOrganism", type: "pharmaWien:assayOrg",
//subjectType: "AssayOrganism:", //subjectType: "AssayOrganism:",
label: "Organism", label: "Bioassay organism",
description: "selection", //description: "selection",
value: "", value: "",
component: "selection", component: "selection",
freefield: false, freefield: false,
...@@ -1257,11 +1257,13 @@ const fields = [ ...@@ -1257,11 +1257,13 @@ const fields = [
visible: true, visible: true,
vocabulary: "assay_organism", vocabulary: "assay_organism",
stateVoc: "assay_organism", stateVoc: "assay_organism",
category: ["assayOrganism"], category: ["assay"],
subcategory: ["assayOrganism"],
multiplicable: true, multiplicable: true,
info: info:
"The organism related to the target / meta-target of the bioassay. It includes both bacterium and eukaryote.", "The organism related to the target / meta-target of the bioassay. It includes both bacterium and eukaryote.",
infoRef: "BAO:0000551" infoRef: "http://www.bioassayontology.org/bao#BAO:0000551",
description: "Bioassay organism:"
}, },
{ {
id: "0-Organism-assayTarget", id: "0-Organism-assayTarget",
...@@ -1269,7 +1271,7 @@ const fields = [ ...@@ -1269,7 +1271,7 @@ const fields = [
type: "pharmaWien:assayTarget_organism", type: "pharmaWien:assayTarget_organism",
//subjectType: "AssayOrganism:", //subjectType: "AssayOrganism:",
label: "Assay Target Organism", label: "Assay Target Organism",
description: "Organism", description: "Bioassay Target organism",
value: "", value: "",
component: "selection", component: "selection",
freefield: false, freefield: false,
...@@ -1298,8 +1300,9 @@ const fields = [ ...@@ -1298,8 +1300,9 @@ const fields = [
ontClass: "NCBITaxon_131567", ontClass: "NCBITaxon_131567",
topId: "NCBITaxon_131567", topId: "NCBITaxon_131567",
component: "ext-service", component: "ext-service",
category: ["assayOrganism"], category: ["assay"],
description: "Cellular organism", subcategory: ["assayOrganism"],
description: "Bioassay organism:",
info: "" info: ""
}, },
{ {
...@@ -1316,7 +1319,8 @@ const fields = [ ...@@ -1316,7 +1319,8 @@ const fields = [
ontClass: "NCBITaxon_10239", ontClass: "NCBITaxon_10239",
topId: "NCBITaxon_10239", topId: "NCBITaxon_10239",
component: "ext-service", component: "ext-service",
category: ["assayOrganism"], category: ["assay"],
subcategory: ["assayOrganism"],
description: "Viruses", description: "Viruses",
info: "" info: ""
}, },
...@@ -1334,7 +1338,8 @@ const fields = [ ...@@ -1334,7 +1338,8 @@ const fields = [
ontClass: "NCBITaxon_12884", ontClass: "NCBITaxon_12884",
topId: "NCBITaxon_12884", topId: "NCBITaxon_12884",
component: "ext-service", component: "ext-service",
category: ["assayOrganism"], category: ["assay"],
subcategory: ["assayOrganism"],
description: "Viroids", description: "Viroids",
info: "" info: ""
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment