Skip to content

Commit

Permalink
Add modality raml
Browse files Browse the repository at this point in the history
  • Loading branch information
nagem committed Feb 21, 2017
1 parent b93d806 commit eb90940
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/config.py
Expand Up @@ -141,6 +141,7 @@ def apply_env_variables(config):
'file.json',
'group-new.json',
'group-update.json',
'modality.json',
'note.json',
'packfile.json',
'permission.json',
Expand Down
1 change: 1 addition & 0 deletions raml/api.raml
Expand Up @@ -51,6 +51,7 @@ resourceTypes:
/gears: !include resources/gears.raml
/devices: !include resources/devices.raml
/rules: !include resources/rules.raml
/modalities: !include resources/modalities.raml
/groups: !include resources/groups.raml
/collections: !include resources/collections.raml
/sessions: !include resources/sessions.raml
Expand Down
8 changes: 8 additions & 0 deletions raml/examples/input/modality-new.json
@@ -0,0 +1,8 @@
{
"_id": "MR",
"classifications": {
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
}
}
7 changes: 7 additions & 0 deletions raml/examples/input/modality-update.json
@@ -0,0 +1,7 @@
{
"classifications": {
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
}
}
10 changes: 10 additions & 0 deletions raml/examples/output/modality-list.json
@@ -0,0 +1,10 @@
[
{
"_id": "MR",
"classifications": {
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
}
}
]
8 changes: 8 additions & 0 deletions raml/examples/output/modality.json
@@ -0,0 +1,8 @@
{
"_id": "MR",
"classifications": {
"Contrast": ["B0", "B1", "T1", "T2", "T2*", "PD", "MT", "ASL", "Perfusion", "Diffusion", "Spectroscopy", "Susceptibility", "Velocity", "Fingerprinting"],
"Intent": ["Structural", "Functional", "Localizer", "Shim", "Calibration"],
"Features": ["Quantitative", "Multi-Shell", "Multi-Echo", "Multi-Flip", "Multi-Band", "Steady-State", "3D", "Compressed-Sensing", "Eddy-Current-Corrected", "Fieldmap-Corrected", "Gradient-Unwarped", "Motion-Corrected", "Physio-Corrected"]
}
}
77 changes: 77 additions & 0 deletions raml/resources/modalities.raml
@@ -0,0 +1,77 @@
description: Utility functions for modalities and their acceptable classifications.
get:
description: |
List all modalities and their classifications.
Requires login.
responses:
200:
body:
application/json:
example: !include ../examples/output/modality-list.json
schema: !include ../schemas/output/modality-list.json
post:
description: |
Insert a modality type and its classifications map.
Requires admin.
body:
application/json:
example: !include ../examples/input/modality-new.json
schema: !include ../schemas/input/modality.json
responses:
200:
body:
application/json:
example: |
{
"inserted": "1"
}
/{ModalityName}:
description: Perform actions with a specific modality
uriParameters:
ModalityName:
type: string
get:
description: |
Get modality details.
Requires login.
responses:
200:
body:
application/json:
example: !include ../examples/output/modality.json
schema: !include ../schemas/output/modality.json
404:
description: Modality not found
put:
description: |
Replace a modality's classifications map.
Requires admin.
body:
application/json:
example: !include ../examples/input/modality-update.json
schema: !include ../schemas/input/modality.json
responses:
200:
body:
application/json:
example: |
{
"modified": "1"
}
404:
description: Modality not found
delete:
description: |
Remove a modality.
Requires admin.
responses:
200:
body:
application/json:
example: |
{
"modified": "1"
}
404:
description: Modality not found
30 changes: 30 additions & 0 deletions raml/schemas/definitions/modality.json
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"definitions": {
"_id": {
"maxLength": 64,
"minLength": 2,
"pattern": "^[0-9a-zA-Z_-]*$"
},
"classifications": {
"type": "object",
"patternProperties": {
"^[0-9a-zA-Z_-]*$":{
"type": "array",
"items": {
"type": "string"
}
},
},
},
"modality":{
"type": "object",
"properties": {
"_id": {"$ref":"#/definitions/_id"},
"classifications": {"$ref":"#/definitions/classifications"}
},
"additionalProperties": false
}
}
}
5 changes: 5 additions & 0 deletions raml/schemas/input/modality.json
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
"required": ["classifications"]
}
8 changes: 8 additions & 0 deletions raml/schemas/output/modality-list.json
@@ -0,0 +1,8 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type":"array",
"items":{
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
"required":["_id", "classifications"]
}
}
5 changes: 5 additions & 0 deletions raml/schemas/output/modality.json
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf":[{"$ref":"../definitions/modality.json#/definitions/modality"}],
"required": ["_id", "classifications"]
}
51 changes: 51 additions & 0 deletions test/integration_tests/abao/abao_test_hooks.js
Expand Up @@ -23,6 +23,7 @@ var test_project_1 = null;
var test_project_tag = 'test-project-tag';
var delete_project_id = '';
var device_id = 'bootstrapper_Bootstrapper'
var modality_name = 'MR'

// Tests we're skipping, fix these

Expand Down Expand Up @@ -1493,3 +1494,53 @@ hooks.before("GET /devices/{DeviceId} -> 404", function(test, done) {
test.request.params.DeviceId = 'bad_device_id';
done();
});

hooks.before("GET /modalities/{ModalityName} -> 200", function(test, done) {
test.request.params.ModalityName = modality_name;
done();
});

hooks.before("GET /modalities/{ModalityName} -> 404", function(test, done) {
test.request.params.ModalityName = 'bad_modality_name';
done();
});

hooks.before("POST /modalities/ -> 200", function(test, done) {
test.request.body = {
"_id":"MR",
"classifications": {
"intent": ["functional"]
}
}
done();
});

hooks.before("PUT /modalities/{ModalityName} -> 200", function(test, done) {
test.request.params.ModalityName = modality_name;
test.request.body = {
"classifications": {
"intent": ["localizer"]
}
}
done();
});

hooks.before("PUT /modalities/{ModalityName} -> 404", function(test, done) {
test.request.params.ModalityName = 'bad_modality_name';
test.request.body = {
"classifications": {
"intent": ["localizer"]
}
}
done();
});

hooks.before("DELETE /modalities/{ModalityName} -> 200", function(test, done) {
test.request.params.ModalityName = modality_name;
done();
});

hooks.before("DELETE /modalities/{ModalityName} -> 404", function(test, done) {
test.request.params.ModalityName = 'bad_modality_name';
done();
});

0 comments on commit eb90940

Please sign in to comment.