[schema] Fix the full filepath for measures and modify relations cardinality and add ALL_MEASURES variable
authorVincent Michel <vincent.michel@logilab.fr>
Wed, 09 Jan 2013 16:40:59 +0100
changeset 22 4fd887fe2c9f
parent 21 e54c4e701491
child 23 b309136b814a
[schema] Fix the full filepath for measures and modify relations cardinality and add ALL_MEASURES variable
entities.py
schema.py
--- a/entities.py	Fri Dec 14 17:20:16 2012 +0100
+++ b/entities.py	Wed Jan 09 16:40:59 2013 +0100
@@ -16,3 +16,22 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 
 """cubicweb-brainomics entity's classes"""
+import os.path as osp
+
+from cubes.medicalexp.entities import compute_fullfilepath
+from cubes.neuroimaging.entities import Scan
+from cubes.genomics.entities import GenomicMeasure
+
+
+class BrainomicsScan(Scan):
+
+    @property
+    def full_filepath(self):
+        return compute_fullfilepath(self)
+
+
+class BrainomicsGenomicMeasure(GenomicMeasure):
+
+    @property
+    def full_filepath(self):
+        return compute_fullfilepath(self)
--- a/schema.py	Fri Dec 14 17:20:16 2012 +0100
+++ b/schema.py	Wed Jan 09 16:40:59 2013 +0100
@@ -24,9 +24,10 @@
 from cubes.genomics.schema import GenomicMeasure, ColumnRef
 from cubes.medicalexp.schema  import Assessment, ProcessingRun, ScoreDef, ScoreValue
 
+ALL_MEASURES = ('GenericMeasure', 'QuestionnaireRun', 'GenericTestRun', 'Scan', 'GenomicMeasure')
 
-ALL_MEASURES = ('GenericTestRun', 'QuestionnaireRun', 'Scan', 'GenomicMeasure')
 
+# ProcessingRun -> Measure
 ProcessingRun.add_relation(SubjectRelation('QuestionnaireRun', cardinality='**'), name='inputs')
 ProcessingRun.add_relation(SubjectRelation('Scan', cardinality='**'), name='inputs')
 ProcessingRun.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='inputs')
@@ -35,32 +36,41 @@
 ProcessingRun.add_relation(SubjectRelation('Scan', cardinality='**'), name='outputs')
 ProcessingRun.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='outputs')
 
+# Maesure -> Subject
+QuestionnaireRun.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*', inlined=True), name='concerns')
+Scan.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*', inlined=True), name='concerns')
+GenomicMeasure.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*', inlined=True), name='concerns')
 
-QuestionnaireRun.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
-Scan.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
-GenomicMeasure.add_relation(SubjectRelation(('Subject', 'Group'), cardinality='1*'), name='concerns')
-
+# Assessment -> Measure
 Assessment.add_relation(SubjectRelation('QuestionnaireRun', cardinality='**'), name='uses')
 Assessment.add_relation(SubjectRelation('Scan', cardinality='**'), name='uses')
 Assessment.add_relation(SubjectRelation('GenomicMeasure', cardinality='**'), name='uses')
 
-Assessment.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*'), name='generates')
-Assessment.add_relation(SubjectRelation('Scan', cardinality='?*'), name='generates')
-Assessment.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*'), name='generates')
+Assessment.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*', inlined=True), name='generates')
+Assessment.add_relation(SubjectRelation('Scan', cardinality='?*', inlined=True), name='generates')
+Assessment.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*', inlined=True), name='generates')
+
+# Score -> Measure
+ScoreValue.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*', inlined=True), name='measure')
+ScoreValue.add_relation(SubjectRelation('Scan', cardinality='?*', inlined=True), name='measure')
+ScoreValue.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*', inlined=True), name='measure')
 
-ScoreValue.add_relation(SubjectRelation('QuestionnaireRun', cardinality='?*'), name='measure')
-ScoreValue.add_relation(SubjectRelation('Scan', cardinality='?*'), name='measure')
-ScoreValue.add_relation(SubjectRelation('GenomicMeasure', cardinality='?*'), name='measure')
-
+# Use for filepath computation
+QuestionnaireRun.add_relation(SubjectRelation('Study', cardinality='1*', inlined=True), name='related_study')
+Scan.add_relation(SubjectRelation('Study', cardinality='1*', inlined=True), name='related_study')
+GenomicMeasure.add_relation(SubjectRelation('Study', cardinality='1*', inlined=True), name='related_study')
 
-QuestionnaireRun.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
-Scan.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
-GenomicMeasure.add_relation(SubjectRelation('Device', cardinality='?*'), name='uses_device')
+# Device -> Measure
+QuestionnaireRun.add_relation(SubjectRelation('Device', cardinality='?*', inlined=True), name='uses_device')
+Scan.add_relation(SubjectRelation('Device', cardinality='?*', inlined=True), name='uses_device')
+GenomicMeasure.add_relation(SubjectRelation('Device', cardinality='?*', inlined=True), name='uses_device')
 
+# Measure -> ExternalResources
 Questionnaire.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
 Scan.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
 GenomicMeasure.add_relation(SubjectRelation('ExternalResource', cardinality='*1'), name='external_resources')
 
+# Various relations
 Questionnaire.add_relation(SubjectRelation('ScoreDef', cardinality='*?'), name='definitions')
 ScoreDef.add_relation(SubjectRelation('Question', cardinality='**'), name='used_by')
 AnatomicalRegion.add_relation(SubjectRelation('ScoreValue', cardinality='**'), name='concerned_by')